export type CreateApiUsersPasswordResetCodeArgs = {body: {email: string}}; export type CreateApiUsersPasswordResetCodeOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Register a code to reset the password * * POST /users/password-reset-code */ export const createApiUsersPasswordResetCode = async (args: CreateApiUsersPasswordResetCodeArgs, options: CreateApiUsersPasswordResetCodeOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/users/password-reset-code${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };