I was trying to make a html file with form to send notification for my react-native app users.
I am using expo push notification, when I try to execute this code:
const sendNotification = async (token, titre, news) => {
const message = {
to: token,
sound: 'default',
title: titre,
body: news,
data: { data: 'goes here' },
};
var request = new Request('https://exp.host/--/api/v2/push/send');
const url = 'https://exp.host/--/api/v2/push/send';
await fetch(request, {
method: 'POST',
headers: {
Accept: 'application/json',
'Accept-encoding': 'gzip, deflate',
'Content-Type': 'application/json',
},
body: JSON.stringify(message),
});
};
I got CORS error.
I make some research about this and I find a lot of things about node js web app but nothing about pure js in an html file..
Any solution?