Category
Expected or Desired Behavior
Hey, I was able to make Slack API calls using the class way (CEWP) plus jQuery and $.ajax.
Now I'm trying to learn SPFx and figure out how to make REST calls to 3rd party apis but I'm getting the error below.
Observed Behavior
Access to fetch at 'https://slack.com/api/users.list?token=&channel=' from origin 'https://localhost:4321' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
On the Left side I have my webpart running in the Local workbench, the Right side is the classic example

This is my code:

private makeRequest(): Promise<HttpClientResponse> {
const token =
"";
const channel = "";
const url = `https://slack.com/api/users.list?token=${token}&channel=${channel}`;
const requestHeaders: Headers = new Headers();
requestHeaders.append("Content-type", "application/json");
requestHeaders.append("accept", "application/json");
const httpClientOptions: IHttpClientOptions = {
headers: requestHeaders,
method: "GET"
};
return this.context.httpClient
.get(url, HttpClient.configurations.v1, httpClientOptions)
.then(response => {
console.log(response);
return response.json();
});
}
Any help would be appreciated.
Category
Expected or Desired Behavior
Hey, I was able to make Slack API calls using the class way (CEWP) plus jQuery and $.ajax.
Now I'm trying to learn SPFx and figure out how to make REST calls to 3rd party apis but I'm getting the error below.
Observed Behavior
On the Left side I have my webpart running in the Local workbench, the Right side is the classic example

This is my code:
Any help would be appreciated.