Answer the question
In order to leave comments, you need to log in
401 error when POST request React?
I don't know much about such requests, especially in React :)
Here is the React code:
import React from 'react';
export default class Request extends React.Component {
componentDidMount() {
var request = new XMLHttpRequest();
var data = {
'grant_type': "client_credentials",
'user_name': "4"};
request.open('POST', 'http://172.20.95.19/token', true);
request.setRequestHeader('Authorization', 'Basic *********');
request.setRequestHeader('Accept', 'application/json');
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request.setRequestHeader('withCredentials', true);
request.setRequestHeader("Access-Control-Allow-Origin", "*");
request.send(data);
}
render() {
return (
<ul>
<p>a</p>
</ul>
)
}
}
OPTIONS http://172.20.95.19/token 401 ()
localhost/:1 Failed to load http://172.20.95.19/token: Response for preflight does not have HTTP ok status.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question