Common functionalities

There are a few functionalities that we used earlier and some extra functionality to consider before jumping further into development. For example, we used a common headers definition, found under public/src/common/headers.ts:

import { Headers } from 'angular2/http';

const HEADERS = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
};

export const contentHeaders = new Headers(HEADERS);

This is simply a way to define constants and use them across the application without repeating yourself. So, basically, we imported Headers from Angular 2 and created a new instance. You can easily add extra fields to this header instance using the append() method, like this for example:

contentHeaders.append('Authorization', ...

Get MEAN Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.