Skip to content

Instantly share code, notes, and snippets.

@jaydson
Created March 8, 2021 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaydson/17b7f5b483f81f6a86a7a54e3307e85d to your computer and use it in GitHub Desktop.
Save jaydson/17b7f5b483f81f6a86a7a54e3307e85d to your computer and use it in GitHub Desktop.
// 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