I want to organize functions based on their specific roles in the code
Here's the situation: when I'm making an http request, I want to separate the function that handles attaching the access token and headers from the one responsible for actually making the http call
In my reset password form (reset-password.html), I have:
<button (click)="tryResetPassword()">Reset Password>
In the reset-password.ts
file:
tryResetPassword(){
..fetch form data
return this._authService.resetPassword()
.subscribe(
...handle response here
)
}
In the authService:
resetPassword(data):Observable<any>{
const body = JSON.stringify(data);
return this.httpClient.post(this.authUrl + '/default/resetPwd', body)
.map(
res=>{
//set access token
return true
}
)
}
Now in the _httpClient
:
post(url, data) {
let headers = new Headers();
this.createGeneralHeaders(headers);
return this.http.post(url+this.accessToken, data, {
headers: headers
});
After running the app, I'm encountering an error:
this._httpclient.post(...).map is not a function
Note: the http in the httpClient refers to angular2 http passed through the constructor
Where am I making a mistake?