Answer the question
In order to leave comments, you need to log in
When I try to authorize, I get an error 400, what could be the problem?
I have a backend request to log in and get a token. When I make a request, I get a 400 error. I think I didn't pass the data correctly. When I try to make a request simply through the console, everything is fine for me - the token is returned to me. Here is an example of correct curl to get a token curl -X POST 127.0.0.1:8000/api/user/token --data "username=default&password=HLhm*Ppsv2q!AXG"
This is how I make a request to the server:
I pass the token and any password there ..
create(token) {
try {
return axios.post(`http://127.0.0.1:8000/api/user/token/`, {
username: token,
password: "1234",
});
} catch (e) {
return e;
}
},
};
Answer the question
In order to leave comments, you need to log in
axios sends json, and from the console you send form-data.
Since you are making a request to the localhost, then you have access to the code. See what you expect.
const formData = new FormData();
formData.append('username', 'token');
formData.append('password', '1234');
return axios.post(`http://127.0.0.1:8000/api/user/token/`, formData);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question