This commit is contained in:
Mike Fitzpatrick
2019-08-06 14:58:01 -04:00
parent b8ddc54b99
commit 637794ebcd
7 changed files with 58 additions and 43 deletions

View File

@@ -11,7 +11,7 @@ import { API_URL } from '../constants/constants.js';
const DefaultRequestOptions = {};
export const API_ENDPOINTS = {
const endpoints = {
// Events and Items
GET_EVENTS: '/events',
// GET_ITEMS: '/items?eventId=:event_id',
@@ -23,13 +23,13 @@ export const API_ENDPOINTS = {
PLACE_BID: '/bids/:item_id',
PURCHASE_ITEM: '/sales',
// Login
LOGIN: '/auth',
// User/Profile
USER_SIGNUP: '/signup',
USER_PROFILE: '/users/:user_id',
VALIDATE_SIGNUP_EMAIL: '/signup/validate/email',
VALIDATE_SIGNUP_NOM: '/signup/validate/nom',
// Services
APPLE_SIGNUP: '/auth/apple/login',
APPLE_LINK: '/auth/apple/link',
@@ -45,11 +45,11 @@ const cacheBuster = () => {
};
export const getEndpointUrl = (endpoint) => {
if (!API_ENDPOINTS[endpoint]) {
if (!endpoints[endpoint]) {
throw new Error('Invalid API endpoint specified');
}
return `${API_URL}${API_ENDPOINTS[endpoint]}`; //`${cacheBuster()}`;
return `${API_URL}${endpoints[endpoint]}`; //`${cacheBuster()}`;
};
export const requestGet = (path, queryParams = [], requestOptions = {}) => {