Examples of "post(url: string, body: string, options?: RequestOptionsArgs) : Observable<Response>"


Can I get some examples using the post() method of Http in Ionic 2
Suppose I want to send a JSON object containing username and pasword to a file ‘’ and return some JSON object.
Please help me with some examles.

How do I send a JSON (serialized if possible ) through http POST method

you can find example https://angular.io/docs/ts/latest/guide/server-communication.html


Maybe something like this? Psuedo code:

import "rxjs/Rx"; // required for the .map function
import {Http, Headers} from "angular2/http";

// Prepare object
let object = { username: "myUsername", password: "myPassword"};

// Start the post function and process the response
this.post(object).then(response => {

// Post function
post: (object: Object) : Promise<JSON> => {       
     let headers = new Headers(); 
     headers.append("Content-Type", 'application/json');  
     return this.http.post("", JSON.stringify(object), { headers: headers  }).map((response) => {                
          return response.json();

EDIT: Added the required imports.