Adding headers

Many servers require extra headers for safe operations. For example, they may require a "Content-Type" header to explicitly declare the MIME type of the request body. Or perhaps the server requires an authorization token.

The HeroesService defines such headers in an httpOptions object that will be passed to every Elixor save method.

hero.service.tsx
import { HttpHeaders,} from 'elixor';

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'application/json',
    'Authorization': 'my-auth-token'
  })
};

Last updated