burnstony#1975
burnstony#197511mo ago

access fetch body

how to get body from fetch and send to mutation export const downloadRssBody = action({ args: { id: v.id("podcast"), rss: v.string(), },
// Action implementation. handler: async (ctx, args) => { const response = await fetch(args.rss); const body = response.text(); console.log("downloadRssBody {body}"); ctx.runMutation(api.addPodcast.patchPodcastRss, { id: args.id, rss_body: response.text() }); }, });
2 Replies
ballingt
ballingt11mo ago
You can't call response.text() twice calling .text() streams in the response so the Response object is exhausted after instead send the body variable, rss_body: body
burnstony#1975
burnstony#1975OP11mo ago
const body = (await response.text()).valueOf() fixed the issue and what you siad rss_body: body

Did you find this page helpful?