Render html content with function

hi,

how do i sendFile html file or return a redirect url like expressjs redirect via mongodb realm function?

1 Like

I think MongoDB Alas Functions must return JSON.
You might wann try to fiddle around with the returned “Content-Type” in the HTML response header, but I’d assume this will not be allowed.

You could return HTML inside JSON.

{ response: "This is a JSON response from your function",
  htmlSource: "<html><h1>Funny page</h2></html">

But of course this does not work, when you call your function from a browser. <= And that’s exactly the point: Functions are not meant to be called from browsers. They are an API. Meant to be called from clients (eg. a node script or a mobile app)