Last active
February 17, 2023 10:29
-
-
Save rjpkuyper/4e785435849bfa21bf1e864508c281a0 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 = (logger) => { | |
error: e => logger.error(`Something bad happened today: ${e}`) | |
} | |
export const createUrl = (path: Paths, url = process.env.BASE_URL) => `${url}${path}` | |
export const loggerService = createLogger(console) | |
export const createHttpGet = (logger, request) => | |
(url: string) => request(url) | |
.catch(logger.error) | |
.then(e => e.json()) | |
export const getProducts = createHttpGet(loggerService, fetch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment