Why do I receive error 419?

0 like 0 dislike
71 views
Hello! Make the authorization on the project and faced with the fact that when sending data, the server returns 419.
Here is my html code:
Authorization 

Here is the function that is responsible for data transfer:
function auth(){ var email = document.getElementById('email').value; var password = document.getElementById('password').value; var tokenHeader = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); var postdata = new Headers({ 'Content-Type': 'application/json', 'X-CSRF-TOKEN': tokenHeader }); var url = '{!!route('login')!!}'; fetch(url,{ method: 'POST', postdata, body: JSON.stringify({email: email, password:password, ' _token: '{!!csrf_token()!!}'}) }).then((response)=>{ return response.json(); }).then((data)=>{ console.log(data) }).catch((error)=>{ console.log(error) }); }

And here is the response from the server:
5be84a49c6f06351019583.png
asked by | 71 views

2 Answers

0 like 0 dislike
You just added the markup in a hidden field @csrf? The token must otpravlyatsya in the body of the Request each request type (GET exception).
answered by
0 like 0 dislike
Judging by Your two screenshots in kommentariyah, it is clear that the tokens are different. Judging by the js code, it is also 2 different token pass. Do this:
body: JSON.stringify({email: email, password:password, ' _token: tokenHeader})

But, if You use the header token, why would it even during data transfer indicate?
answered by

Related questions

0 like 0 dislike
1 answer
asked Sep 30, 2018 by sk1llmuf
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Sep 26, 2018 by rusline18
0 like 0 dislike
2 answers
asked Nov 12, 2018 by lemonlimelike
24,509 questions
45,932 answers
0 comments
345 users