Add api call for all projects
This commit is contained in:
parent
baa48f86e0
commit
eb6529c233
2 changed files with 11 additions and 3 deletions
|
@ -1,9 +1,16 @@
|
||||||
import endpoints from './endpoints';
|
import endpoints from './endpoints';
|
||||||
import request from './request';
|
import request from './request';
|
||||||
|
import token from './token';
|
||||||
|
|
||||||
export function checkToken(token) {
|
export function checkToken(possibleToken) {
|
||||||
const url = endpoints.get('USER_INFO');
|
const url = endpoints.get('USER_INFO');
|
||||||
return request(url, 'GET', {}, token).then(function (response) {
|
return request(url, 'GET', {}, possibleToken).then(function (response) {
|
||||||
return response.ok;
|
return response.ok;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getProjects() {
|
||||||
|
const CIToken = token.get();
|
||||||
|
const url = endpoints.get('ALL_PROJECTS');
|
||||||
|
return request(url, 'GET', {}, CIToken);
|
||||||
|
}
|
||||||
|
|
|
@ -4,5 +4,6 @@ import UrlAssembler from 'url-assembler';
|
||||||
const URL_BASE = UrlAssembler('https://circleci.com/api/v1');
|
const URL_BASE = UrlAssembler('https://circleci.com/api/v1');
|
||||||
|
|
||||||
export default Map({
|
export default Map({
|
||||||
USER_INFO: URL_BASE.segment('/me')
|
USER_INFO: URL_BASE.segment('/me'),
|
||||||
|
ALL_PROJECTS: URL_BASE.segment('/projects')
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue