Created
April 4, 2021 10:21
-
-
Save dodicandra/7f3c8963bd7ef8916682206f132438be to your computer and use it in GitHub Desktop.
fcm with http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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