Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
export class MessagesService {
constructor(private http: Http) {
getMessageOfTheMoment(): Promise<string> {
return this.http.get('api/get-message-of-the-moment')
.then(response => response.json().message)
postMessage (message: string): Promise<any> {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return'api/post-message', { message }, options)
.then(response => response.json())
private handleError(error: any): Promise<any> {
console.error('Oh noooo! An error occurred', error); // for demo purposes only
return Promise.reject(error.message || error);