ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 278.4k

error when create service res.json is not a function

Dec 30 2019 1:55 AM
I work on angular 7
I create service take array of locations then make forjoin between them 
but i get error as following :
error when create service res.json is not a function
 
  1. core.js:15724 ERROR TypeError: res.json is not a function  
  2.     at MapSubscriber.project (part-details.service.ts:56)  
  3.     at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:35)  
  4.     at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)  
  5.     at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)  
  6.     at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)  
  7.     at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:38)  
  8.     at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)  
  9.     at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:84)  
  10.     at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:15)  
  11.     at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)  
and this is my code
  1.       getLocationData(ids: Array<number>) {    
  2.         let observableBatch = [];  
  3.       
  4.       ids.forEach((id) => {  
  5.       
  6.             observableBatch.push(  
  7.                   this.http.get('http://192.168.7.45:9200/location/_doc/'+id)  
  8.                          
  9.                           .map((res: any) => res.json()));  
  10.         });  
  11.       
  12.         return Observable.forkJoin(observableBatch);  
  13.     }  
  14.       
  15.       //--------------------------------  
  16.   
  17. }  
 error show display here 
 
How to solve this problem please ?
 
I pass array of locationid to url to get gps1 
from json returned from function  then i mkae forkjoin between them 

Answers (1)