About Axios Code Generator
Fill in the request and copy Axios code that sends it, for a browser app, Node.js or a script tag. Choose between the shorthand methods such as axios.post() and a single axios({ … }) config object, and between async/await and a .then() chain.
JSON bodies become a plain object that Axios serialises for you, form fields become URLSearchParams, and notes under the code explain anything it adjusted, such as a Content-Type header it added or a header that browsers will not send.
How it works
- The URL is checked and written the way it will be sent, with unsafe characters escaped. Headers are read one per line.
- The body goes into a data constant first, so the call itself stays short. JSON becomes an object literal; form fields become URLSearchParams.
- Where Axios would guess wrong, the code says what it means: a text body gets Content-Type: text/plain, and JSON that cannot be rebuilt exactly is sent as the text you wrote.
- Everything happens in this page. Nothing is sent, including the request you describe.
Questions
Does the code need to check the status code?
No. Unlike fetch, Axios rejects its promise for any status outside 200 to 299, so an error response lands in catch with error.response holding the details.
What does the script tag option change?
It leaves out the import line, for pages that load Axios from a script element and use the global axios object. The rest of the code is the same.
Why is a large ID sent as text?
JavaScript numbers hold integers exactly only up to 9,007,199,254,740,991. Rebuilding a JSON body with a larger one would quietly change it, so the body is sent exactly as you typed it, labelled as JSON.
Is my token sent or saved anywhere?
No. This tool only writes code, and the form is not saved in the address bar, so a token in a header stays out of your history.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.