17 lines
481 B
JavaScript
17 lines
481 B
JavaScript
import token from './token';
|
|
|
|
export default function request(url, method, data = {}, CIToken) {
|
|
CIToken = CIToken || token.get();
|
|
const fullURL = url.query({ 'circle-token': CIToken }).toString();
|
|
console.log('Sending request to', fullURL);
|
|
let fetchParams = {
|
|
method,
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
},
|
|
};
|
|
if (method !== 'GET' && method !== 'HEAD') {
|
|
fetchParams.body = JSON.stringify(data);
|
|
}
|
|
return fetch(fullURL, fetchParams);
|
|
}
|