Created
July 17, 2018 14:14
-
-
Save gjacobrobertson/74367dde47fd5b0a1fc1f7de0d75a4c3 to your computer and use it in GitHub Desktop.
This file contains 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
function createFetcher<Params, Return>(endpoint: (params: Params) => string, handler: (obj: any) => Return) { | |
return _debounce((params: Params) => { | |
fetch(API_BASE_URL + endpoint(params), DEFAULT_GET_OPTIONS) | |
.then(response => response.json()) | |
.then(handler); | |
}, 200); | |
} | |
export const findMarketingAsset = createFetcher( | |
({ id = null } = {}) => `/assets/${id}`, | |
jsonArray => new MarketingAsset(jsonArray[0]), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment