I have created a Rest API in Java with the request Mapping(/value/generate).
System.out.println(value);
if(!value.equals(null)){
return new ResponseEntity(value, HttpStatus.OK);
}
return new ResponseEntity(HttpStatus.FORBIDDEN);
}
Value is getting printed in Console when iam call this through postman.
But i need to print this value in my Angular console.
Below is code i have created in angular.
service.ts
generatevalue(): Observable<String> {
return this.http.get('https://localhost:8080/value/generate')
Component.ts
ngOnInit() {
this.service.generatevalue().subscribe((Response) => {
console.log(Response)
}
}
Please let me know where i went wrong.
httpforlocalhost. Angular should still be smart enough to run it successfully nonetheless, but just a tip. Other than that, this could be related to CORS (an issue Postman would not run into). But as others have mentioned, check your console first and see what the actual API response is.