Skip to content

Instantly share code, notes, and snippets.

@tiagosiebler
Created November 16, 2022 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagosiebler/acb80b2bd1ba4737de6a280c919749fc to your computer and use it in GitHub Desktop.
Save tiagosiebler/acb80b2bd1ba4737de6a280c919749fc to your computer and use it in GitHub Desktop.
CURL from axios options request
function buildCurlRequest(options: AxiosRequestConfig): string {
let curlQuery = '';
curlQuery += `curl --location --request ${options.method} '${options.url}'`;
for (const header in options.headers) {
curlQuery += `\\\n --header '${header}: ${options.headers[header]}'`;
}
return curlQuery;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment