-
-
Save mansurissa/488bf7205101021d3fea6a68ea798c15 to your computer and use it in GitHub Desktop.
Quick directions on how to use notification endpoints
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
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