Zac
Zac

Reputation: 23

Angular 4 http get request - Exception: A network error occured

I am trying to connect my ionic / angular app to a spring boot back end. I check the back end with postman and am able to get a result from the get request. When I do it with my app I get "A network error occurred". I am just learning angular - but I do another get request to firebase - and that request works fine. After doing some research ppl suggested it might be related to CORS - I have Cross Origins enabled on the spring boot app - also downloaded the extension to turn off just to make sure.

Any help would be great! Code below.

Error Message

localhost:8080

Springboot Controller

(from service)

getTimesheets() {
    console.log('Service: getTimesheets()')
    console.log('URL: ' + this.url)

    return this.http
        .get(this.url)
        .subscribe(data => {
            console.log(data)
        });
}

(from timesheet.ts)

getTimeSheets() {
    this.timeSheetService.getTimesheets()
  }

Upvotes: 0

Views: 504

Answers (1)

Zac
Zac

Reputation: 23

I fixed it - I forgot the 'http://' in front of the url...

Upvotes: 1

Related Questions