UNPKG

@youngshand/payload-auth-plugin

Version:

A temporary fork for testing of Authentication plugin for Payload CMS, use @payload-auth-plugin

23 lines (22 loc) 524 B
// src/client/hooks.ts import * as qs from "qs-esm"; var getCurrentUser = async (options, queryOpts) => { const base = process.env.NEXT_PUBLIC_SERVER_URL; let query = ""; if (queryOpts) { query = "?"; if (queryOpts.fields) { query += qs.stringify({ fields: queryOpts.fields }); } } const response = await fetch(`${base}/api/${options.name}/session${query}`); const { message, kind, data } = await response.json(); return { message, kind, data }; }; export { getCurrentUser };