@kosalam2 wrote:
Hi Im going to call http post method using ionic 2.but in the response always im getting error.can any one help me.
this is my json type
{
“username”:”user”,
"password":”pass"
}
This is my codeimport {Page, NavController} from 'ionic-angular'; import {Http, Headers, RequestOptions} from 'angular2/http'; import 'rxjs/Rx'; @Page({ templateUrl: 'build/pages/home/home.html' }) export class HomePage { constructor(http: Http, nav: NavController) { this.http = http; this.makePostRequest(); } makePostRequest() { var headers = new Headers(); headers.append('Content-Type', 'application/json'); this.http.post('url', JSON.stringify({ username: 'admin', password: 'a' }), { headers: headers }) .map((res: Response) => res.json()) .subscribe((res) => console.log("res", res)); } }
error Log
4 236980 log DEVICE READY FIRED AFTER, 1437, ms 5 237420 group EXCEPTION: [object Object] 6 237426 error EXCEPTION: [object Object] 7 237431 error STACKTRACE: 8 237433 error 9 237435 groupEnd 10 237525 error Uncaught #<Response>, http://192.168.1.13:8100/build/js/app.bundle.js, Line: 7834
How can i solve this.?
Posts: 1
Participants: 1