This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/api/CircleCI.js

21 lines
537 B
JavaScript
Raw Normal View History

2016-02-06 12:42:19 +00:00
import endpoints from './endpoints';
import request from './request';
2016-02-10 22:42:45 +00:00
import token from './token';
2016-02-06 12:42:19 +00:00
2016-02-21 11:59:53 +00:00
function JSONify(response) {
return response.json();
}
2016-02-10 22:42:45 +00:00
export function checkToken(possibleToken) {
2016-02-06 12:42:19 +00:00
const url = endpoints.get('USER_INFO');
2016-02-10 22:42:45 +00:00
return request(url, 'GET', {}, possibleToken).then(function (response) {
2016-02-06 12:42:19 +00:00
return response.ok;
});
}
2016-02-10 22:42:45 +00:00
2016-02-21 11:59:53 +00:00
export async function getProjects() {
const CIToken = await token.get();
2016-02-10 22:42:45 +00:00
const url = endpoints.get('ALL_PROJECTS');
2016-02-21 11:59:53 +00:00
return await request(url, 'GET', {}, CIToken).then(JSONify);
2016-02-10 22:42:45 +00:00
}