Cast data to json from API
This commit is contained in:
parent
44d004c598
commit
51ebef35be
1 changed files with 7 additions and 3 deletions
|
@ -2,6 +2,10 @@ import endpoints from './endpoints';
|
||||||
import request from './request';
|
import request from './request';
|
||||||
import token from './token';
|
import token from './token';
|
||||||
|
|
||||||
|
function JSONify(response) {
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
export function checkToken(possibleToken) {
|
export function checkToken(possibleToken) {
|
||||||
const url = endpoints.get('USER_INFO');
|
const url = endpoints.get('USER_INFO');
|
||||||
return request(url, 'GET', {}, possibleToken).then(function (response) {
|
return request(url, 'GET', {}, possibleToken).then(function (response) {
|
||||||
|
@ -9,8 +13,8 @@ export function checkToken(possibleToken) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProjects() {
|
export async function getProjects() {
|
||||||
const CIToken = token.get();
|
const CIToken = await token.get();
|
||||||
const url = endpoints.get('ALL_PROJECTS');
|
const url = endpoints.get('ALL_PROJECTS');
|
||||||
return request(url, 'GET', {}, CIToken);
|
return await request(url, 'GET', {}, CIToken).then(JSONify);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue