Skip to content

Instantly share code, notes, and snippets.

@mansurissa
Created October 12, 2021 04:52
Show Gist options
  • Save mansurissa/488bf7205101021d3fea6a68ea798c15 to your computer and use it in GitHub Desktop.
Save mansurissa/488bf7205101021d3fea6a68ea798c15 to your computer and use it in GitHub Desktop.
Quick directions on how to use notification endpoints
Getting all notification: `/api/users/notifications`
Getting one notification: `/users/notifications/12`
Notify all by admin: `/api/users/notifyAll`, body:{"title":"Sponsored notifications test",
"body":"This is for testing notify all"}
Nofify either organizers or users: `/api/users/notifyUsersOrOrganizers`, body:{
"title":"sponsored notifications organizers",
"body":"this is for testing notify user or organizers",
"to":"ORGANIZER" // remember to always capitalize this and the other only available option is "USER"
}
and here is the simple frontend that I have created for just testing: ` <script src="/socket.io/socket.io.js"></script>
<script>
document.querySelector('.btn').addEventListener('click', e => {
e.preventDefault();
const token = document.querySelector('.token').value;
const socket = io({
query: {
token
}
});
socket.on('newNotification', data => {
console.log(data);
});
});
</script>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment