HTTP CORS - ERROR Access-Control-Allow-Origin


#1

Text translated by google (French -> English)

Hello, I appeal to you because I have a problem.

I’m trying to retrieve API information with an API key provided. But that does not work.

When I make the request on “Postman”, it works for me. However, when I make the request in the code of my application ionic blank, I have errors.

My code:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as unirest from "unirest";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  public test: any;
  constructor(public navCtrl: NavController) {

    var req = unirest("GET", "https://api.fortnitetracker.com/v1/profile/psn/labourine");

    req.headers({
      "Postman-Token": "475064f1-5b36-466e-b7f4-61a86d2f194c",
      "Cache-Control": "no-cache",
      "TRN-Api-Key": "API-key",
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, PATCH, DELETE",
      "Access-Control-Allow-Credentials": true,
    });


    req.end(function (res) {
      this.test = res.body;
      console.log(res.body);
    });

  }

}

My first mistake:

image

To deal with this, I installed CORS on google. However, it brings me back to a second mistake:

image

How to do ? Because it works on postman and when I use another API it works even in my code.

Thank you in advance.