Skip to content

Return data from mutate #155

@sergiodxa

Description

@sergiodxa

Now that mutate support passing an async function to get the data it will be helpful to get that data as return value of mutate.

const data = await mutate('/api/data', fetch('/api/data').then(res => res.json()))
// use data

This way if I want to use the data right now for something else I don't need to use the old way of first fetch and await and then pass the data to mutate and return it below.

const data = await fetch('/api/data').then(res => res.json());
mutate('/api/data', data)
// use data

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions