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.
Your url should probably be " http://localhost:8080/value/generate ". Did you check your console for errors? It should print an error 404 somewhere.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.