export default class ApiService {
async get(endpoint, token) {
return await fetch(`http://66.97.36.76:4000/api${endpoint}`, {
method: 'GET',
mode: 'cors',
headers: {
Accept: 'application/json',
'Content-type': 'application/json',
Authorization: `Bearer ${token}`,
},
}).then((res) => {
return res.json().then((body) => {
if (res.status === 200) {
return body;
}
if (res.status === 403) {
console.log('no token de la api');
} else {
throw Error(body.message);
}
});
});
}