Skip to content

Instantly share code, notes, and snippets.

@Sampath-Lokuge
Created December 17, 2017 08:13
Show Gist options
  • Save Sampath-Lokuge/9aceef97251d209500632b8c58d9594f to your computer and use it in GitHub Desktop.
Save Sampath-Lokuge/9aceef97251d209500632b8c58d9594f to your computer and use it in GitHub Desktop.
patch
@Sampath-Lokuge
Copy link
Author

I just hard coded value:

changeSupportedLanguage() {
        this.userService.patchMyProfile(['fr']);
    }

  patchMyProfile(languages: string[]) {
        return this.apiService.patch(`${config.myProfile}`, { languages: languages }).map((res: any) => res.json());
    }
patch(url, params): Observable<any> {
        return new Observable(observer => {
            let header = new Headers();
            this.createHeader(header)
                .then(() => {
                    let options = new RequestOptions({ headers: header });
                    this.http.patch(url, params, options)
                        .subscribe(response => {
                            observer.next(response);
                            observer.complete();
                        }, (e) => {
                            observer.error(e);
                        });
                })
        })
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment