Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from "@angular/core";
- import { Http, Headers, Response } from "@angular/http";
- import { Observable } from "rxjs/Rx";
- import "rxjs/add/operator/do";
- import "rxjs/add/operator/map";
- import { User } from "./user";
- import { Config } from "../config";
- @Injectable()
- export class UserService {
- constructor(private http: Http) {}
- register(user: User) {
- let headers = new Headers();
- headers.append("Content-Type", "application/json");
- return this.http.post(
- Config.apiUrl + "Users",
- JSON.stringify({
- Username: user.email,
- Email: user.email,
- Password: user.password
- }),
- { headers: headers }
- )
- .catch(this.handleErrors);
- }
- handleErrors(error: Response) {
- console.log(JSON.stringify(error.json()));
- return Observable.throw(error);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement