Hey guys quick question, since I am not sure what I am doing wrong.
I am trying to return my function, but my response body is always empty. what am I doing wrong?
TypeScript
const payload = req.req?.bodyJson || req.req?.body || req.req?.bodyText || req.req?.bodyRaw;
const { action, ...params } = payload;
console.log("Action:", action);
console.log("Params:", params.cors_origin);
console.log(process.env.ACCESS_TOKEN);
console.log(process.env.SECRET_KEY);
try {
let response;
if (action === 'createUploadUrl') {
console.log("Creating upload URL");
// Create the upload URL with Mux API
/*const upload = await mux.video.uploads.create({
cors_origin: params.cors_origin, // '*' for testing; update for production
new_asset_settings: {
playback_policy: ['public'],
video_quality: 'basic'
}
});*/
const test = "Works123";
const temp = { success: true, uploadUrl: test, uploadId: test };
console.log("req.query.type:", req.query.type);
res.setHeader('Content-Type', 'application/json');
return res.json(temp);
}
} catch (error) {
return { success: false, error: error.message };
}
};```
TL;DR
Developers trying to set a header for a response in Appwrite Functions, but encountering an issue where the response body is always empty. To solve this, set the Content-Type header before returning the response.Recommended threads
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...
- Inquiry: How to Reduce Cold Start Durati...
Hey! I was using Python for the function runtime, but after reading that Go has the fastest runtime, I switched my code over to Go. However, I'm still seeing co...
- After a GET request is passed to functio...
Create execution in the console can normally retrieve the get parameters。WHy?