Pablo Musella - 2022-02-21 22:24:42
Hi, i need add the user id information or some key that can identify or segment the database for send push notification (example: send notification to all man 18 years old). If I try to do this by de DOM, i have an error like this: "document is not defined.."
below is the code snippet:
async function pnSaveSubscription(sub) {
var body = JSON.parse(JSON.stringify(sub));
//##### this is where I need to take information from an html field to store a key or id next to the subscription ######
body.user_id = document.getElementById('user_id').value;
// ######
var fetchdata = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
};
var response = await fetch(strSubscriberURL, fetchdata);
return await response;
}