[Ionic 4] [HELP] Converting from HttpClient to Native HTTP

Hi there,

I get a CORS error on the API service. To overcome this problem, I need to use the Native HTTP plug-in. I don’t know how to use native HTTP. My codes are below. And I don’t know how to use features like infinite scrolling with Native HTTP.

Can someone help me?



import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

  providedIn: 'root'
export class LaunchService {
  public apiUrl: any = 'https://xxxxxx.com/api/3.3.0/';
  currentArticle: any;

  constructor(private http: HttpClient) { }

  getApi(offset) {
    console.log('next: ', offset);
    const url = this.apiUrl + 'upcoming/?offset=' + offset + '&mode=detailed';
    return this.http.get(url);


import { HttpClient } from '@angular/common/http';
import { ApiService } from './../launch.service';
import { Component } from '@angular/core';
import { LoadingController } from '@ionic/angular';

  selector: 'app-tab2',
  templateUrl: 'tab2.page.html',
  styleUrls: ['tab2.page.scss']
export class Tab2Page {

  data: any = [];
  offset = 0;

  constructor(private launchService: ApiService, private http: HttpClient, public loadingController: LoadingController) {}

  ngOnInit() {
    .subscribe(data =>{
      this.data = data;

  //infinity scroll start
    this.offset += 20;
    .subscribe(data =>{
      for(const article of data['results']){
  //infinity scroll end

Isn’t there anyone to help in the big forum?!!

Well, I don’t think switching to the native http will solve your CORs problem.

Do you have any control over the server, I suspect you will need to enable remote access on the server?

server does not belong to me. i told the owner of the server. He said he’d be interested.

Will Native HTTP not work for CORS?

CORs has to be enabled on the server. Do a Google search, it is a well documented problem. Native is no different to any other access.

1 Like

I told them. I am waiting answer. But they don’t care much.

I wrote an article to resolved Http options while making API Calls using Cordova advanced HTTP plugin, it will help you please check the below link

1 Like

Thank you, I will review the article!

Is this what you need to look at ?

It’s not descriptive.

Hi mate, Are you able to fixed it? I am facing a same problem.

For security, We avoid allowing localhost in the server which cause CORS issue and to overcome it, We use http native. But it has some limitation