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() }); }, });
// 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
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
const body = (await response.text()).valueOf()
fixed the issue
and what you siad
rss_body: body