Last active
February 17, 2023 09:58
-
-
Save rjpkuyper/8634b9325e05eec006c5e2aab2dd89ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export enum Paths { | |
PRODUCTS = '/products' | |
} | |
export const createLogger = () => { | |
error: e => console.error(`Something bad happened today: ${e}!`) | |
} | |
export const loggerService = createLogger() | |
export const createUrl = (path: Paths) => `${process.env.BASE_URL}${path}` | |
export const productsUrl = createUrl(Paths.PRODUCTS) | |
export const getProducts = () => fetch(productsUrl).catch(loggerService.error).then(e => e.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment