Correções de segurança
This commit is contained in:
@@ -118,7 +118,14 @@
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(async response => {
|
||||
const text = await response.text();
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch (e) {
|
||||
throw new Error(`Resposta inválida do servidor (${response.status}): ${text.substring(0, 100)}...`);
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
this.$dispatch('notify', {
|
||||
type: data.success ? 'success' : 'error',
|
||||
@@ -127,10 +134,11 @@
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erro no teste:', error);
|
||||
this.$dispatch('notify', {
|
||||
type: 'error',
|
||||
title: 'Erro',
|
||||
message: 'Falha na requisição.'
|
||||
message: 'Erro: ' + error.message
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
Reference in New Issue
Block a user