Add new methods in api.js #2
This commit is contained in:
parent
af1f17bfc5
commit
c022e8bb3c
|
@ -1,9 +1,26 @@
|
||||||
var API_URL = 'https://api.dribbble.com/shots/';
|
"use strict";
|
||||||
|
|
||||||
|
var API_URL = "https://api.dribbble.com/v1/",
|
||||||
|
ACCESS_TOKEN = "7a22f910dcdff63bd3ebbe48d022f05e8268c67249709b5489d923f97bcf96ec";
|
||||||
|
|
||||||
|
function fetchData(URL) {
|
||||||
|
return fetch(URL, {
|
||||||
|
headers: {
|
||||||
|
"Authorization": "Bearer " + ACCESS_TOKEN
|
||||||
|
}
|
||||||
|
}).then((response) => response.json())
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getShotsByType: function(query: string, pageNumber: ?number): string {
|
getShotsByType: function(type: string, pageNumber: ?number): ?Object {
|
||||||
return (
|
var URL = API_URL + "shots/?list=" + type;
|
||||||
API_URL + query + '/' + '?per_page=20&page=' + pageNumber
|
if (pageNumber) {
|
||||||
);
|
URL += "&per_page=10&page=" + pageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fetchData(URL);
|
||||||
|
},
|
||||||
|
getResources: function(url: ?string): ?Object {
|
||||||
|
return fetchData(url);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue