Skip to content

Collection: Custom Data Parameter #57

@kristianbinau

Description

@kristianbinau

Clear and concise description of the problem

For some of my endpoints I require that the user sends their password to confirm the action (like account deletion).

I'm not sure if there's a good solution currently to requiring "custom" data in the hooks.

export default RStoreSchema.withItemType<User>().defineCollection({
	name: 'User',
	hooks: {
		delete: ({ key }) =>
			$fetch(`/api/app/users/me/delete`, {
				method: 'POST',
				body: {
					// Can't get currentSessionPassword from parameters
					currentSessionPassword: currentSessionPassword,
				},
			}),
	},
});

Suggested solution

A parameter that can be defined for each hook, so that custom data can be included.

Alternative

I considered moving the logic of opening a modal and requesting the password into the hook, but that also seems a little cursed...

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions