const http$ = Observable.create(observer => {
fetch('api/courses')
.then( response => {
return response.json();
})
.then(body => {
observer.next(body);
observer.complete();
})
.catch(err => {
observer.error(err);
});
});
http$.subscribe(
courses => console.log(courses),
noop,
() => console.log('completed')
);