Skip to content

Instantly share code, notes, and snippets.

Last active August 18, 2017 17:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save giridharprakash/21863151c0963151ca5cd0671f955f6a to your computer and use it in GitHub Desktop.
Send JSON in Http Get request with Angular.
import {Http, Headers, RequestOptions, Response, ResponseContentType, URLSearchParams} from "@angular/http";
export class DocumentService
constructor(private http: Http)
loadDocuments(folderId: number, currentPage: number) : Observable<Response>
let headers = new Headers({
'Content-Type' : 'application/json',
'Accept': 'application/json'
let requestOptions = new RequestOptions({headers});
requestOptions.params = this.getFilterData(currentPage);
let path = "folders/"+folderId+"/documents";
return this.http.get(appConstants.apiUrl+ path, requestOptions );
private getFilterData(currentPage: number) : any
let params: URLSearchParams = new URLSearchParams();
let filterValue = JSON.stringify( {currentPage: currentPage, pageLimit: 50 });
params.set('filter', filterValue);
return params;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment