I have a REST API that is accepting two parameters that are username and password and giving the result as true or false on the basis of user input at front end. I am facing some issue in calling the REST API to my angular 8 code.
SPRING REST API
@RequestMapping(value = "/checkData", method = RequestMethod.POST)
public String Authentication(@RequestParam("username") String username, @RequestParam("password") String password) {
}
I am trying to access the given API through my angular 8 app through services and defined the service as follows :
AuthLoginInfo.ts
export class AuthLoginInfo {
username: string;
password: string;
constructor(username: string, password: string) {
this.username = username;
this.password = password;
}
}
checkLogin(userInfo : AuthLoginInfo){
return this.http.post(`${API_URL}/APP/checkData/${userInfo.username}/
${userInfo.password}`,{},{responseType: 'text'})
}
But when I am running my app I am not getting the params in proper format. Can anyone tell me how to define the request params in HTTP POST API ?
Thank you in advance for your suggestions.
api_url/APP/checkData/yourUsername/yourPassword?