Back

[SOLVED] How to add value to headers in Cloud Functions

  • 0
  • Self Hosted
  • Web
  • Cloud
Ahmed Ibrahim
7 Nov, 2023, 08:33

Hi I know that to return response from Appwrite cloud function I do the following

TypeScript
 return context.res.send(body);

but how can I add value to the returned header. For example

TypeScript
final tokens = 10;
// I want to add the variable "tokens" to the hader of the returned response
return context.res.send(body);

In the above example I want to **append ** the tokens to the **header **not the body

TL;DR
The user wants to know how to add a value to the headers in Cloud Functions. The solution is to use the `send` function and pass the headers as a third parameter. Example code is provided.
ideclon
7 Nov, 2023, 10:07

You can do

TypeScript
send(body, 200, {
    "tokens": "…",
})
Ahmed Ibrahim
7 Nov, 2023, 11:13

Great, thanks

Drake
8 Nov, 2023, 00:17

Can this be marked as solved now?

Ahmed Ibrahim
8 Nov, 2023, 00:17

Yes

Drake
8 Nov, 2023, 00:18

[SOLVED] How to add value to headers in Cloud Functions

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more