mr.nobody4704Original post
Rank 1: Thread
I was working with my project and when everything is done, I want it to send a response to the client side just like the examples had done
return res.send("done", 200, headers);
but when i do that, it says
Return statement missing. return context.res.empty() if no response is expected.
you can see my code here
https://github.com/dev-shammi/Test/blob/main/src%2Fmain.js#L199
I also tried to use throw instead of return but it doesn't work as well.
I just want it to send the response from that block of code, I have tried removing separate functions for all my code blocks and merging all into one, but that also didn't work.
Summary
To send a response using `res.send()` from a nested function, you can pass `res` as a parameter to the nested function. Here's an example snippet based on your code:
```javascript
function myNestedFunction(res) {
// Your nested logic
res.send("done", 200, headers);
}
// Call the nested function with 'res'
myNestedFunction(res);
```
This way, you can access and use `res` inside the nested function to send the response.