Skip to content

Instantly share code, notes, and snippets.

@chizhovdee
Created August 27, 2021 08:32
Show Gist options
  • Save chizhovdee/0014fd91ac7f012a943be7ed20dfad66 to your computer and use it in GitHub Desktop.
Save chizhovdee/0014fd91ac7f012a943be7ed20dfad66 to your computer and use it in GitHub Desktop.
export const API = {
getDirections: 'getDirections',
// others
}
const stringifyQuery = (query) => !isEmpty(query) ? `?${qs.stringify(query)}` : ''
const API_URLS = {
[API.getDirections]: (params, query) => `${__DOMAIN__}/backend/api/directions/${params.direction}${stringifyQuery(query)}`
}
export const getApiUrl = (apiKey, params, query) => API_URLS[apiKey](params, query)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment