S
S
Sergey Burduzha2021-03-25 12:00:33
css
Sergey Burduzha, 2021-03-25 12:00:33

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))
    }


What didn't I learn?

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2018-03-16
@danilstep

onclick="return OnClick1();"
possible without return

R
Ross Alex, 2021-03-25
@serii81

in fetch

mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin'

and from the server side Headers:
Access-Control-Allow-Origin: * // или referer server name
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS

D
Dima Pautov, 2021-03-25
@bootd

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 question

Ask a Question

731 491 924 answers to any question