Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Last active June 23, 2016 16:50
Show Gist options
  • Save aaronmcadam/9b5372a9b849a3fbb934a4c1b46ad3eb to your computer and use it in GitHub Desktop.
Save aaronmcadam/9b5372a9b849a3fbb934a4c1b46ad3eb to your computer and use it in GitHub Desktop.
import { curry } from 'ramda';
const makeRequest = curry((endpoint, tokenResponse) => {
const token = bizApi.accessToken.create(tokenResponse);
const accessToken = token.token.access_token;
return bizApi.api('GET', endpoint, { access_token: accessToken });
});
/**
* Makes a GET request to the Business API
* @param {string} endpoint The endpoint we wish to call
* @returns {Promise} A promise containing the requested data
*/
const callBizApi = (endpoint: string): Promise<any> => {
return requestToken(credentials).then(makeRequest(endpoint));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment