L
L
letMeDie2019-06-13 19:04:42
Node.js
letMeDie, 2019-06-13 19:04:42

Error on post request (axios)?

So here is the request code

axios.post("http://localhost/users/personalInfo", {
            id: "142288"
        }).then(response=>{
            alert();
        }).catch(error=>{
            console.log(error);
        })

And this is the handler on the server (node ​​js with express)
app.post("/users/personalInfo", (req, res) => {
    res.setHeader("access-control-allow-credentials", "true");
    res.setHeader("access-control-allow-origin", "http://localhost:3000");
    // let newData = {...personalInfoData, [req.params.user]: req.params.user}
    console.log("Checked");
    res.send("Found");
});

As I understand it, the request does not even reach the server, two errors crash
Error: Network Error
    at createError (createError.js:17)
    at XMLHttpRequest.handleError (xhr.js:80)
OPTIONS http://localhost/users/personalInfo?user=142288 net::ERR_CONNECTION_REFUSED

I would be grateful if you could help me figure out what is wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-06-13
@letMeDie

Forgot to specify the port in the request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question