JSFiddle - React, Tailwind, and code Playground

by edwardsharp

HTML

<div ng-app ng-controller="jsonp_thingy">
    <button ng-click="doRequest()">Make JSONP request</button>
</div>

JavaScript

// pop open yr console

function jsonp_callback(data) {
    // returning from async callbacks is (generally) meaningless
    console.log(data.found);
}

function jsonp_thingy($scope, $http) {
    $scope.doRequest = function() {
        var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=jsonp_callback";

        $http.jsonp(url);
    };

    var url = "http://public-api.wordpress.com/rest/v1/sites/wtmpeachtest.wordpress.com/posts?callback=jsonp_callback";

    $http.jsonp(url);
}