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
- core.js:15724 ERROR TypeError: res.json is not a function
- at MapSubscriber.project (part-details.service.ts:56)
- at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:35)
- at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
- at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)
- at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
- at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/operators/filter.js.FilterSubscriber._next (filter.js:38)
- at FilterSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
- at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:84)
- at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:15)
- at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
and this is my code
- getLocationData(ids: Array<number>) {
- let observableBatch = [];
-
- ids.forEach((id) => {
-
- observableBatch.push(
- this.http.get('http://192.168.7.45:9200/location/_doc/'+id)
-
- .map((res: any) => res.json()));
- });
-
- return Observable.forkJoin(observableBatch);
- }
-
-
-
- }
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