Cast data to json from API

This commit is contained in:
Jake Howard 2016-02-21 11:59:53 +00:00
parent 44d004c598
commit 51ebef35be

View file

@ -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);
} }