Adicione o token JWT no cabeçalho
function getAllClients() {
const myHeaders = new Headers({
'Content-Type': 'application/json',
'Authorization': 'your-token'
});
return fetch('http://localhost:8080/clients', {
method: 'GET',
headers: myHeaders,
})
.then(response => {
if (response.status === 200) {
return response.json();
} else {
throw new Error('Something went wrong on api server!');
}
})
.then(response => {
console.debug(response);
}).catch(error => {
console.error(error);
});
}
getAllClients();
Smiling Squirrel