angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 232 forks source link

Angular HttpClient Post invoking Web API Post method multiple times #126

Open nsksaisaravana opened 7 years ago

nsksaisaravana commented 7 years ago

Hi, below Angular code invoking the WebApi POST method multiple times, please help me to resolve this.

import { Injectable } from '@angular/core';
import { HttpClient,HttpErrorResponse,HttpHeaders,HttpParams} from '@angular/common/http';
import {IUserInfo} from './user-info';
import {Observable} from 'rxjs/Observable';
import {Http,Response,RequestOptions,Headers} from '@angular/http';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/map';

 saveNewPersonDetails(personDetails){
    const headers = new HttpHeaders().set('Content-Type', 'application/json; charset=utf-8');

    return this._http.post(this._webApiUrl + "person",personDetails, {headers: headers})
    .subscribe(personData => this.personData=personData);
  }
wardbell commented 7 years ago

I don't know what you mean by multiple times. Can't do anything about it until I understand.

Also, please note that right now this library only supports Angular's Http module. Support for HttpClient will arrive with PR #130.