Angular 9 Intercom API, how to fix CORS error?

906 Views Asked by At

I'm trying to access intercom API and create a company there using their API https://developers.intercom.com/intercom-api-reference/reference#create-or-update-company but getting CORS error!

URL = 'https://api.intercom.io/companies'

this.httpOptions = {
    headers: new HttpHeaders({
      'Content-Type':  'application/json',
      'Authorization': 'Bearer ....',
      'Access-Control-Allow-Origin': '*'
    })
 };

const path = this.URL + '/companies';
return this.http.post(path, data, {headers: this.httpOptions});

enter image description here

How to fix CORS error?

1

There are 1 best solutions below

0
Rajat Masih On BEST ANSWER

Intercome apis doest not work in the client side. You need use server side package to make api call on intercome.

You can use one of them:

1- Nodejs http client package : axios

2- Official node package : intercom-node