0
votes

Alerte ne pas montrer quand je fais une réponse transmise

}).then(response => {
                    if (response.status === 500 ){
                        alert(error.response.data.message);
                    }
                    else { 
                    window.location.replace("/admin/users/"+this.user.id);
                }

0 commentaires

3 Réponses :


0
votes

Modifiez votre réponse comme suit:

return response(['message' =>  "That's less than 6, not allowed"], 500);


0 commentaires

0
votes

Partmètres pour l'aide de la réponse sont Réponse (String Message, int Status_Code, Array? En-têtes)

Si vous ne retournez pas l'usage JSON Réponse de retour () -> JSON (Array JSON, INT Statut_code, Array? En-têtes)

Pour plus d'informations Voir la documentation https://laravel.com/docs /7.x/helpers#method-response


0 commentaires

1
votes

Comment je gère Axios est ci-dessous Pour d'abord, retournez votre réponse de Laravel comme ceci. (Inclure le code d'état) em> xxx pré>

Après cela sur votre côté Axios, obtenez le message comme celui-ci p>

axios.post().then(function(response){
                // this will run if the status code is 200 in laravel response
               // Get passed data like 'response.data.message', You will get your passed values after 'response.data'
            }).catch(function(error){
                notify('error', error.response.data.message); // You will get your passed values after 'error.response.data'
            })


0 commentaires