Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

YMD's avatar
Level 1

Using POST method with ReactJS

I'm incorporating ReactJS with Laravel but a little clueless as to how to use the POST method. Here are extracts of my attempt.

submit(){ fetch('/words', { method: 'POST', headers: { //'Accept' and 'Content-Type', 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), }, body: JSON.stringify({ property: property information }) }) }

render() { return ( //Input tags here Save ); }

The URL, '/words', lead to the store( ) function, but pressing this Save button (i.e. calling submit( ) function) leads to TokenMismatchException in VerifyCsrfToken.php.

Does anyone have a good idea as to calling POST with ReactJS?

Any advice will be appreciated,

0 likes
1 reply

Please or to participate in this conversation.