I'm trying to use Microsoft Teams WebHook to send notification when an user submit a bug within my Vue.js application but I'm having a CORS error...
Here is my code :
const webhookUrl =
"https://outlook.office.com/webhook/XXX";
const card = {
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
summary: "New bug",
sections: [
{
activityTitle: "A <b>bug</b> has been submitted!",
},
{
title: "Details:",
facts: [
{
name: "Name",
value: this.bug.author,
},
{
name: "Description",
value: this.bug.content,
},
],
},
],
};
Axios.post(webhookUrl, card, {
headers: {
Accept: "application/json",
"content-type":
"application/vnd.microsoft.teams.card.o365connector",
},
})
.then(() => {
this.$toasted.succes("Thanks for helping us !");
})
.catch((e) => {
console.log(e);
this.$toasted.error(
"There was an error while trying to submit your bug"
);
});
Where "XXX" is my WebHook code, it works perfectly when performing a POST request with Postman..
Thanks in advance for your help !