TypeError: res.json(...).catch is not a function


Not sure what is going on…I am getting the above error. This is the method in the service I am calling.

return Observable.forkJoin(
this.http.get(‘https://randomuser.me/api/?nat=gb’).map((res:Response) => res.json())
.catch((error:any) => Observable.throw(error.json().error || ‘Server error’)),
this.http.get(‘https://randomuser.me/api/?nat=fr’).map((res:Response) => res.json()
.catch((error:any) => Observable.throw(error.json().error || ‘Server error’)))

Here is where I am calling it:

data => {
this.name1 = data[0];
this.name2 = data[1];
err => { console.error(“Error:” + err) }

It isn’t breaking my app. But a strange error that I can’t figure out - anything obvious I am missing popping out?

I have the following imports in my service

import { Observable } from ‘rxjs/Observable’;
import ‘rxjs/add/observable/forkjoin’;
import ‘rxjs/add/operator/map’;
import ‘rxjs/add/observable/throw’;
import ‘rxjs/add/operator/catch’;

Any help would be greatly appreciated.

You are missing a ‘)’ here:
this.http.get(‘https://randomuser.me/api/?nat=fr’).map((res:Response) => res.json()


legend, couldn’t see the wood for the trees.

when you can use or import HttpClient then res.json() not working but when you can use old http and import only Http then res.json() is working.