Skip to content

Instantly share code, notes, and snippets.

@dodicandra
Created April 4, 2021 10:21
Show Gist options
  • Save dodicandra/7f3c8963bd7ef8916682206f132438be to your computer and use it in GitHub Desktop.
Save dodicandra/7f3c8963bd7ef8916682206f132438be to your computer and use it in GitHub Desktop.
fcm with http
export const httpFcm = async (body: any) => {
const options = {
headers: {
Authorization: auth.token, // tokan dari firebase message: setelan projek => clund messaging => token
'Content-Type': 'application/json'
},
method: 'POST',
data: JSON.stringify(body)
};
try {
const result = await axios({
url: 'https://fcm.googleapis.com/fcm/send',
headers: options.headers,
data: options.data,
method: 'POST'
});
return result.data;
} catch (err) {
console.log(err);
throw err;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment