Created
April 27, 2022 20:00
-
-
Save NathBabs/d2e2af902c154388f32f030b4f84d748 to your computer and use it in GitHub Desktop.
call another endpoint in restify
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
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