import { Observable } from 'rxjs/internal/Observable';
export function createHttpObservable(url: string) {
console.log('Url is', url);
return Observable.create(observer => {
fetch(url)
.then(response => {
console.log(response);
console.log(response.json());
return response.json();
})
.then(body => {
observer.next(body);
observer.complete();
})
.catch(err => observer.error(err));
});
}
I am encountering an issue with the above code where the execution does not progress to the second then block. The browser console logs are shown below.
https://i.sstatic.net/FHIZv.png
Interestingly, if I eliminate the line console.log(response.json());, the code functions correctly. This appears to be a basic question, but I am unable to identify the cause. Any assistance would be greatly appreciated. Thank you in advance.