#TRPC mutate call

1 messages · Page 1 of 1 (latest)

mossy rockBOT
#

Hi @opaque heart. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. The extracts provided do not contain specific information about implementing a searchProminentPlacesMutation with tRPC in a Next.js application.

However, based on the information available, you can use tRPC's mutation functions in a similar way to how it's used in the onDelete function in the measurements.tsx file. Here's the relevant code for reference:

const deleteMeasurement = api.measurements.delete.useMutation();
async function onDelete(): Promise<void> {
  await deleteMeasurement.mutateAsync(selectedId);
  router.refresh();
  router.replace('/');
}

In this example, deleteMeasurement is a mutation function created by useMutation(). When called with mutateAsync(), it performs the mutation and then refreshes the page.

You would need to replace api.measurements.delete.useMutation() with your own mutation function, such as api.searchProminentPlacesMutation.useMutation().

For more detailed information, I recommend checking out the tRPC documentation (https://trpc.io/) or the Next.js documentation (https://nextjs.org/docs/getting-started).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@opaque heart kapa.ai is still learning and improving, please let us know how it did by reacting below

#

Let me check the knowledge base for you. One moment! :books:

#

I'm sorry, but your question is not clear. Could you please provide more details or context? Are you asking about how to create an API with Next.js, or do you have a specific question about using API routes in Next.js? The more details you provide, the better I can assist you.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: