Currently, I have a form field whose value I am passing to a service as this.form.value
. However, when I log this.form.value
on the console, I see
Object { email: "zxzx", password: "zxzxx" }
. Despite this, when I send the same data to the service and make a call to the server with the following code:
import {Http} from 'angular2/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import {Injectable} from 'angular2/core'
import {Post} from './post';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class PostService {
private _url = "http://127.0.0.1/accounts/login_user/";
constructor(private _http:Http) {
}
createPost(post){
return this._http.post(this._url,JSON.stringify(post))
.map(res=>res.json());
}
}
The server is successfully getting called, but unfortunately, the values are not being passed through correctly. Upon logging the response on the console, I get the following result:
Object { _isScalar: false, source: Object, operator: Object }
If anyone could provide some guidance on how to resolve this issue, it would be greatly appreciated.
Thank you.