Extra colon shows up while doing axios post
See original GitHub issueI am trying to do post using axios in Node.js backend. While ‘get’ requests are working fine.r. As soon as i try ‘post’ method, this fails.
Below, i am trying to do a login whose backend in running as well (i have tested it all in postman).
const host = `http://localhost:6800/`;
function loginAdmin(email, password){
return axios.post(`${host}admin/login`,JSON.stringify({email, password}));
}
As soon as this code runs, i find that i am trying to send
{"email":"admin2@always.com","password":"1234"}:
You can see that extra ‘:’ here, which added i don’t know how.
Then i checked backend that what exactly i am receiving there, and i found:
{ '{"email":"admin2@always.com","password":"1234"}': '' }
Which means backend is receiving the data so cors problem does not exist, yet i am not able to understand the reason behind.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Extra semicolon showing up in axios get request
However when the commented out, hard coded version runs it works just fine. At some point an extra semicolon is being added to...
Read more >Understanding Axios POST requests - LogRocket Blog
Learn how to use the Axios POST method in both vanilla JavaScript and in a framework like React to send requests.
Read more >Brand Partnership Guidelines - Axios
We punctuate branded posts the same way we punctuate editorial posts and words rarely appear in all-caps. ○ Axios body text is broken...
Read more >Building a single-page application with Symfony 4, Vue.js ...
In this tutorial, we'll build a very simple application where users can post messages. We'll see how to: setup a development environment with...
Read more >Making HTTP requests with Axios - CircleCI
If you don't have a CircleCI account, sign up for a free one here. ... Next I will show you how to do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
if
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
, read the doc https://github.com/axios/axios#using-applicationx-www-form-urlencoded-formatI am providing valid javascript only. Latest ECMA script allows you to perform this way that if key and value variable is same in javascript, then we can use it this way.
{email: email, password: password}
can be written as{email, password}
, why don’t you give it a shot in browser console 😃 However this is not the problem. It has got something to do withContent-Type: application/x-www-form-urlencoded;charset=UTF-8
, as when i am doing urlendcoding, it then works. Still i don’t know what is this problem, am i suppose to continue like thisconst params = new URLSearchParams();
or not.