J
J
JIexa012018-10-01 12:09:19
CORS
JIexa01, 2018-10-01 12:09:19

Axios how to solve network error problem?

Chrome does not identify this error, but gives out the code, and apparently the matter is in the interaction of axios and API (but this is not accurate) https://www.reddit.com/r/reactjs/comments/66v4pg/c... .
5bb1e3ea7f479336371832.png5bb1e3f720de6243228843.png
Mozilla outputs: "Request from foreign origin blocked: Single origin policy forbids reading remote resource on 'api link here'. (Reason: CORS request failed)." https://developer.mozilla.org/en/docs/Web/HTTP/COR...
Here is the request:

var data = "username=юзернейм&password=пароль"
axios("Cсылка на апи", {
method: 'POST',
async: true,
crossDomain: true,
data: data,
headers: {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"accept-language": "en-US,en;q=0.9,ru;q=0.8",
"content-type": "application/x-www-form-urlencoded",
}
}).then((response) => {
console.log(response)
})
.catch((error) => {
console.log(error)
})

This is an authorization apish and authorization passes successfully, but soon it knocks back, can there be a problem on the client side (mine)? Can anything be done?
I experimented with headers, but to no avail.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2018-10-01
@deliro

Read until you understand

F
Fergos, 2022-01-16
@Fergos

In my case, the error with CORS occurred only on one address, and the AdBlock extension turned out to be the cause. Url contained the following line - ../mark/ ad000 /wordstat . The ad blocker decided that something was being downloaded that it was designed to block .. (ad - (English) advertising).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question