PHP Classes

how to add information in the subscription in the database

Recommend this page to a friend!

      PHP Web Push Notifications Server  >  All threads  >  how to add information in the...  >  (Un) Subscribe thread alerts  
Subject:how to add information in the...
Summary:Add informatio to suscription
Messages:1
Author:Pablo Musella
Date:2022-02-21 22:24:42
 

  1. how to add information in the...   Reply   Report abuse  
Picture of Pablo Musella 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;
}