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
- ClientException with SocketException: Cl...
hi <@564158268319203348> i have noticed this 500 status code in my function requests, it seems its not able to connect to the internet in the function as reque...
- NEW ERROR Invalid document structure: At...
Error: ```AppwriteException: document_invalid_structure, Invalid document structure: Attribute "pb.kmsgxPkgInfo.id_info" must be an array (400)``` I’m encounter...
- Issues with executor in Appwrite 1.9.0
Hi, I’ve recently did a fresh install of appwrite 1.9.0 self hosted and when I run a function, it just waits indefinite This is the error from the log: [Er...