anonymize
Learn how to anonymize users on the server side.
This function dissociates the current session from an identified user. It is the server-side equivalent of the client-side anonymize method.
Call this function when a user logs out of your application to clear their identity. The SDK issues a new anonymous token and updates the corresponding cookie.
Signature
This function has the following signature:
function anonymize(): Promise<void>Example
Here is an example of how to use this function in a server API route:
server/api/logout.post.js
JavaScript
1234567
export default defineEventHandler(async () => { // Your logic to log out the user
await anonymize();
return {success: true};})