Hi @Amol Tidke ,
Please use SPHttpClient to overcome CORS issue:
Getting around CORS issues in SPFx with SPHttpClient
private async postToChannel(msg = "Testing API", channel = this.channel) {
const url = `https://slack.com/api/chat.postMessage?token=${
this.token
}&channel=${this.channel}&text=${msg + " using HttpClient"}`;
return await this.context.httpClient.post(
url,
HttpClient.configurations.v1,
{
mode:"cors",
headers:{
"Content-Type":"application/x-www-form-urlencoded"
}
}
);
}
Here is a similiar issue posted in GitHub for your reference:
Problem making 3rd party API calls using SPFx
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.