lundi 9 juillet 2018

GET 500 (Internal Server Error) laravel/js

I'm trying to send an OTP to a user when the user clicks the button.

so I'm using LARAVEL And I'm returning the response as JSON.

When I click the button I get this error in console :

GET http://domain/resend 500 (Internal Server Error)

I read a question about the same topic the answer said that I have to add CSRF token, I did add it I still get the error.

my js code :

try {
        let resend = await fetch('http://domain/resend',{
            method:'GET',
            headers:{

                'Content-type':'application/json',
                'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content').value
            },
        });
        let resultre = await resend.json();

        return {

            resultre
        }
    }catch (e) {
        console.log(e);
    }

And im returning the laravel reponse :

return response()->json($user->save());

I'm still beginner So my code might not be good,

thank you



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2J4PVMR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire