Skip to content

Instantly share code, notes, and snippets.

@NathBabs
Created April 27, 2022 20:00
Show Gist options
  • Save NathBabs/d2e2af902c154388f32f030b4f84d748 to your computer and use it in GitHub Desktop.
Save NathBabs/d2e2af902c154388f32f030b4f84d748 to your computer and use it in GitHub Desktop.
call another endpoint in restify
function request(bearerToken) {
return function () {
const client = restify.createJSONClient({
url: process.env.GRUPP_API_URL,
version: "*",
});
client.headers.authorization = `Bearer ${bearerToken}`;
return client;
};
}
export const getCustomersUnderBanker = async ({ bearerToken }) => {
try {
const client = request(bearerToken);
return get({
client,
path: "/account/customers",
});
} catch (error) {
throw new Error(error);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment