Lección 6 de 8
Headers y autenticación
Los headers HTTP envían información extra con las peticiones. Content-Type le dice al servidor que envías JSON. Authorization envía un token para demostrar quién eres.
APIS
// Enviar headers con fetch
fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer your-token-here"
},
body: JSON.stringify({ name: "Ali" })
});