I am trying to login to a system. In angular 1, there was ways to set
withCredentials:true
But I could not find a working solution in angu
I think you don't use the post
metrhod the right way. You could try something like that:
onSubmit(event,username,password) {
this.creds = {
'Email': 'harikrishna@gmail.com',
'Password': '01010','RememberMe': true
}
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json');
this.http.post('http://xyz/api/Users/Login',
JSON.stringify(this.creds),
{ headers: headers });
}
You invert parameters. The second parameter corresponds to the content to send into the POST and should be defined as string. Objects aren't supported yet at this level. See this issue: https://github.com/angular/angular/issues/6538.
If you want to set specific headers, you need to add the Headers
object within the third parameter of the post
method.
Otherwise, I think the withCredentials
property is related to CORS if you want to send cookies within cross domain requests. You can have a look at this link for more details:
Hope it helps you, Thierry