Created
March 21, 2018 15:42
-
-
Save kseniya292/57651baf531c2ac1640732c9fb60f1dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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