Updated polling logic.

This commit is contained in:
Mike Cao 2020-10-09 01:04:06 -07:00
parent fdc92d087b
commit 9737127bb1
6 changed files with 33 additions and 19 deletions

View file

@ -28,3 +28,7 @@ export function getQueryString(params = {}) {
return '';
}
export function makeUrl(url, params) {
return `${url}${getQueryString(params)}`;
}

View file

@ -1,4 +1,4 @@
import { getQueryString } from './url';
import { makeUrl } from './url';
export const apiRequest = (method, url, body, headers) =>
fetch(url, {
@ -20,10 +20,10 @@ export const apiRequest = (method, url, body, headers) =>
});
export const get = (url, params, headers) =>
apiRequest('get', `${url}${getQueryString(params)}`, undefined, headers);
apiRequest('get', makeUrl(url, params), undefined, headers);
export const del = (url, params, headers) =>
apiRequest('delete', `${url}${getQueryString(params)}`, undefined, headers);
apiRequest('delete', makeUrl(url, params), undefined, headers);
export const post = (url, params, headers) =>
apiRequest('post', url, JSON.stringify(params), headers);