Using server actions with swagger
Answered
Largehead hairtail posted this in #help-forum
Largehead hairtailOP
I have a would like to use server side components to fetch data directly from the components and when doing a post or a update, use server actions to do so. But is there any way to use swagger to document this? Using api routes, I can indeed do so. But would rather avoid that if possible.
Thanks!
Thanks!
Answered by joulev
server actions are normal javascript functions so you can just document them with jsdoc normally
3 Replies
@Largehead hairtail I have a would like to use server side components to fetch data directly from the components and when doing a post or a update, use server actions to do so. But is there any way to use swagger to document this? Using api routes, I can indeed do so. But would rather avoid that if possible.
Thanks!
server actions are normal javascript functions so you can just document them with jsdoc normally
Answer
@joulev server actions are normal javascript functions so you can just document them with jsdoc normally
Largehead hairtailOP
Question. If I have server actions that do a mutation. Like liked books and reviews and I'm getting books from a 3rd party api. Is it best practice to use routes for the 3rd party api or also put them in a js function?
@Largehead hairtail Question. If I have server actions that do a mutation. Like liked books and reviews and I'm getting books from a 3rd party api. Is it best practice to use routes for the 3rd party api or also put them in a js function?
if, for querying, you use server components to fetch that api, then you should also use server actions to fetch that api for mutations.
if, on the other hands, you fetch the api directly from the browser (with tanstack query for example), then you fetch the api directly from the browser for mutation too.
if, on the other hands, you fetch the api directly from the browser (with tanstack query for example), then you fetch the api directly from the browser for mutation too.