I am beginner web developer.
I make my first project in due and laravel 8.
My API return me error: {"message":"The given data was invalid.","errors":{"email":["Taki email ju\u017c wyst\u0119puje."], "login":["Taki login ju\u017c wyst\u0119puje."]}}
I have this code:
axios.post(this.$apiAdress + '/api/administrators?token=' + localStorage.getItem("api_token"),
self.record
)
.then(function (response) {
if (response.data.status == 'success') {
Swal.fire(
'Sukces',
'Rekord dodany poprawnie!@',
'success'
)
} else {
Swal.fire(
'Błąd',
response,
'error'
)
}
this.$router.replace({path: '/administrators/create'});
}).catch(function (error) {
if (error.response.data.message == 'The given data was invalid.') {
Swal.fire(
'Błąd',
'Proszę wypełnić wszystkie pola oznaczone gwiazdką!',
'error'
)
window.scrollTo({top: 0});
}
In linę: error.response.data.message I have this errors.
I need print errors in Swal:
Swal.fire(
'Błąd',
'.... Here errors ....',
'error'
)
For example:
Swal.fire(
'Błąd',
'Taki email ju\u017c wyst\u0119puje. <br/> Taki login ju\u017c wyst\u0119puje.',
'error'
)
How can I make it?
Please help me