Para usar menos librerías, pueden usar el fetch que es el API por defecto.
Para hacer el POST a la peticion quedaría así
const options = {
method: 'POST',
headers: {
accept: '*/*',
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: email,
password: password,
}),
};
const response = await fetch(endPoints.auth.login, options).then((res) => res.json());
const { access_token } = response;
Y para hacer el GET sería así
const options = {
method: 'GET',
headers: {
authorization: `Bearer ${access_token}`,
},
};
const data = await fetch(endPoints.auth.profile, options).then((res) => res.json());```
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?
o inicia sesión.