Answer the question
In order to leave comments, you need to log in
Why is a fetch request not working?
Good afternoon.
I made a request in postman and it is successful.
There, in the headers, you need to pass 3 parameters, login, password and api key.
Both work, and get and post.
But when I try to fetch data in vue, I get 400 bad reqeust.
created () {
fetch("https://api.agimonline.com/v1/properties/list", {
method: "POST",
mode: "no-cors",
headers: {
"X-Api-User": "###",
"X-Api-Pwd": "###",
"X-Api-Key": "###"
}
}
)
.then(res => res.json())
.then(data => console.log(data))
}
Answer the question
In order to leave comments, you need to log in
in fetch
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin'
Access-Control-Allow-Origin: * // или referer server name
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Well, POST is sending data, not receiving data.
Perhaps this route has a POST request, but it expects data to be transmitted that you do not transmit.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question