Hey Ras, I would like to know how you use server actions with a regular button (not in form) which fire a get/post function onClick :) for example you have an invitation page with a token and you can accept or decile the invitation, so you have 2 buttons "accept" and "deny" and these bottuns execute a server action function which writes to the DB the decision.
Welcome to coding 101 by The Weekend.
😂
i know it's a stupid question but what's a webhook api what's the difference between webhook and normal apis like rest api i don't really get it
I'd watch videos on it so u can full understand my g
many thanks!! 🙏🏻
keep making videos about next. Thanks 🇧🇷
More to come!
do you still beleive actions are better than routes?
I feel like they are harder to debug individually
Hey Ras, I would like to know how you use server actions with a regular button (not in form) which fire a get/post function onClick :) for example you have an invitation page with a token and you can accept or decile the invitation, so you have 2 buttons "accept" and "deny" and these bottuns execute a server action function which writes to the DB the decision.
Here's a piece of code, the deleteBeacon function is a server action
onClick={async (e) => {
e.preventDefault()
try {
const response = await deleteBeacon(info?.id)
queryClient.invalidateQueries({ queryKey: ['get-beacons', user?.id!] })
toast("Beacon deleted")
router.refresh()
return response
} catch (error) {
console.log('error')
Sentry.captureException(error);
toast("Deleting failed")
return
}
is it feasible from deployment point of view to use server actions instead of api routes ? will it result in some sort of problems or not?
there are some cons, will talk about in a video
i think we are not supposed to fetch data using server actions.Right?
we not!! check my updated videos