import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable , from } from 'rxjs' ; import { GuestbookData } from './guestbook.component' ; @ Injectable ( { providedIn : 'root' } ) export class GuestbookService { constructor ( private http ) { } public getGuestbook ( ) { const promise = new Promise < GuestbookData [ ] > ( ( resolve , reject ) => { resolve ( this . dataStore ) ; console . log ( "get" ) ; console . log ( this . dataStore ) ; } ) ; const observable = from ( promise ) ; return observable ; } public postGuestbook ( guestbookData ) { this . dataStore . push ( guestbookData ) ; console . log ( "post" ) ; console . log ( this . dataStore ) ; const promise = new Promise ( ( resolve , reject ) => { resolve ( { } ) ; } ) ; return from ( promise ) ; } dataStore : GuestbookData [ ] = [ { name : 'James' , message : 'Great concert !' } , { name : 'Kate' , message : 'Lot of fun .. thanks' } ] ; }