CORB in Ionic 4 HTTP GET

by Calvin Seng   Last Updated July 13, 2019 01:26 AM

Wondering if someone could point me out where did I code wrongly as I am trying to pull external API request into the app and Chrome renders error

zone.js:3243 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://seo.unamo.com/api/v1/?token=xxxxxx with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

With the right token and if Curl or Access directly in Chrome, the JSON data is showing properly. However when I was trying to load in the app, there is cross origin blocking issue.

Following is part of my service.ts

export class UnamoService {
  url: string = this.appConfig.Unamo_URL + 'api/v1/';
  constructor(private httpClient: HttpClient, public appConfig: AppConfig) { }
  getRecentPositions(): Observable<any> {
    return this.httpClient.get(this.url + "?token=" + this.appConfig.Unamo_Token ).pipe(
      map((positions: Position[]) => {
        return positions.map(() => new Position());
      }),
      catchError(error => {
        return Observable.throw('Something went wrong ;)');
      })
    );
  }
}

And on the page.ts

export class PositionsPage {
  private positions : Position[] = [];
  constructor(
      public loadingController: LoadingController,
      private unamo: UnamoService,
      public navCtrl: NavController,
      public router: Router,
      public userService: UserService,
      public modalView: ModalController) { }

  async ngOnInit() {
    const loading = await this.loadingController.create({
    message: 'Please wait...',
    spinner: 'crescent',
    duration: 2000
  });
    await loading.present();

    this.loadPositions().subscribe(res => {
      this.positions = [...this.positions, ...res];
      loading.dismiss();
    });
  }

  loadPositions() {
    return this.unamo.getRecentPositions();
  }



Related Questions


Geolocation is not working in Ionic 4 Android

Updated March 27, 2019 04:26 AM



In ionic inAppBrowser I want custom close button

Updated July 02, 2019 11:26 AM