forked from fay-jai/toy-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsonpFetcher.js
31 lines (30 loc) · 1.13 KB
/
jsonpFetcher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Implement a function that takes a URL and a callback and makes a JSONP
* GET request to that URL.
*
* We've provided the following API endpoint:
* http://toy-problems.hackreactor.com/jsonparty
*
* Your function should accept a call with that URL, and call the callback
* with the response data from the server. You should NOT return the response
* from the server, only the wrapped data! jQuery is not available, and you won't
* be able to do this using a native XMLHttpRequest.
*
* Example:
* jsonpRequest('http://toy-problems.hackreactor.com/jsonparty', function (data) {
* console.log(data.response); // "Aw yeah, now we're JSONPartying"
* console.log(data.random); // 3558
* });
*
* // Subsequent requests should have properly random responses:
* jsonpRequest('http://toy-problems.hackreactor.com/jsonparty', function (data) {
* console.log(data.random); // 1733
* });
*
* Hint: The API accepts a `callback` parameter. What is that for?
* See http://en.wikipedia.org/wiki/JSONP if you need more information
* about this exciting AJAX protocol!
*
*/
var jsonpRequest = function(url, callback) {
};