• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

149
Views
Unable to get Response from API in angular

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.

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your url should probably be "http://localhost:8080/value/generate". Did you check your console for errors? It should print an error 404 somewhere.

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error