Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created April 17, 2020 21:15
Show Gist options
  • Select an option

  • Save NyaGarcia/fa3d9ff16d12bbd8065c5b55ae74cf6e to your computer and use it in GitHub Desktop.

Select an option

Save NyaGarcia/fa3d9ff16d12bbd8065c5b55ae74cf6e to your computer and use it in GitHub Desktop.
OBservable created with ajax(), with custom headers
// What if we need custom headers? No problem!
const ghibliFilmWithHeaders$ = ajax({
url: 'https://ghibliapi.herokuapp.com/films',
method: 'GET',
headers: {
'Content-Type': 'json'
},
body: {
message: "Custom message 'cause we're so cool"
}
});
ghibliFilmWithHeaders$.subscribe(console.log);
// Output: AjaxResponse {xhr: {}, request: {}...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment