mercredi 9 octobre 2019

CSRF_TOKEN not found even I mentioned it in meta tag

I'm trying to integrate reactjs with laravel . So What I did is , changed my js from vue to react by using some commands. Then I added Example.js file under /resources/js/components . Then I added it in app.js

require('./bootstrap');

require('./components/Example');

my Example.js

import React, { Component } from 'react';
import ReactDOM from 'react-dom';

export default class Example extends Component {
    render() {
        return (
            <div className="container">
                <div className="row justify-content-center">
                    <div className="col-md-8">
                        <div className="card">
                            <div className="card-header">Example Component</div>

                            <div className="card-body">I'm an example component!</div>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

if (document.getElementById('example')) {
    ReactDOM.render(<Example />, document.getElementById('example'));
}

Then I added a component of Example.js in my blade file .

<meta name="csrf-token" content="">
<div class = "content">
    <div id = "Example" class = "title m-b-d">
    </div>
</div>
<script type = "text/javascript" src = "js/app.js"></script>

But I can't able to get the Example.js component in my blade file . In my console, I'm getting this error .

CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token

What am I missing here ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire