Created
March 8, 2021 16:54
-
-
Save jaydson/17b7f5b483f81f6a86a7a54e3307e85d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Podemos instanciar um Header já passando um objeto | |
// com as propriedades que queremos setar | |
let headers = new Headers({ | |
'Content-Type': 'text/plain', | |
'X-Custom-Header': 'valor' | |
}); | |
// mas também podemos adicionar programaticamente | |
// depois de já termos instanciado | |
headers.append('X-Custom-Header', 'valor'); | |
// além disso podemos checar, pegar ou setar valores | |
headers.get('Content-Type'); // "text/plain" | |
headers.set('Content-Type', 'application/json'); | |
headers.has('Content-Type'); // true | |
// assim como deletar propriedades de Header | |
headers.delete('X-Custom-Header'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment