i am trying to send a post request to my spring rest api using angular and its http library.
currently in post-man (sucessfully) i am sending the data in this way:
- The format is form-data
- The key is reqData(mandatory)
- The Value is json(mandatory)
how to send the data in the same way via angular?
currently, this is how my data looks like:
onSignIn(form: NgForm) {
const email = form.value.email;
const password = form.value.password;
const reqData = {
'app_uname': email,
'app_pass': password
};
}
adding more about my backend code:
my rest api looks like this:
@RequestMapping(value = "/login", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<String> handle(@RequestParam(value = "reqData") String reqData,HttpServletRequest request)
so i should be sending a key and value ( i am not aware which data structure in typescript,but in java it is MultiValueMap) where the key is reqData and the value should be json in string or json object.
how to make my reqData json in angular to MultiValueMap format?
i have tried both formData and Map also:
const formData: FormData = new FormData();
formData.append('reqData', JSON.stringify(reqData));
const map = new Map();
map.set('reqData', reqData);
