Skip to content

Instantly share code, notes, and snippets.

@kseniya292
Created March 21, 2018 15:42
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 kseniya292/57651baf531c2ac1640732c9fb60f1dd to your computer and use it in GitHub Desktop.
Save kseniya292/57651baf531c2ac1640732c9fb60f1dd to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class EmailService {
constructor(private http: Http) { }
sendEmail(data) {
return this.http.post('http://localhost:1337/email/', data)
.map(res => res.json())
.catch(this._errorHandler);
}
private _errorHandler(error: Response) {
console.error(error);
return Observable.throw(error || 'Server Error')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment