Search code examples
javascriptgoogle-cloud-functionsresponse

Do something after returning a response?


Im looking for a way to do the following:

return res.send(response).then({
    someFunc()
  })

After the send() occurs the then() block runs allowing me to call some function in the backend.

Is there a way to do this?

What I currently have above yields an error:

Parsing error: Unexpected token } eslint


Solution

  • You can see eslint can't parse your code. Inside the then method is a function but you're sending an object with the curly braces.

    return res.send(response).then((result) => {
      someFunc();
    });