3

I have some request I want to perform, and until now I used the http.post with json's like this:

this.http.post("https://somepath.com/users/login", JSON.stringify({"email": "[email protected]","password":"123","user_token":"sss"}), RequestOptionsArgs);

but this won't work since this request to this website needs to be form-data body...how can I take this same call and change it to be form-data?

thanks!

1
  • try removing JSON.stringify( Commented Sep 12, 2016 at 11:13

1 Answer 1

5

As i can see in Angular 2 tests you should use FormData object. ie:

let body = new FormData();
body.append('email', '[email protected]');
body.append('password', '123');
this.http.post("https://somepath.com/users/login", body);
Sign up to request clarification or add additional context in comments.

1 Comment

Here I can get the status as 200 Ok. But from using this how can I redirect to another page?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.