# No output from lambda function?

**URL:** <https://answers.netlify.com/t/no-output-from-lambda-function/19824>\
**Category:** Support\
**Tags:** lambda-functions\
**Created:** [July 30, 2020, 1:00pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824 "2020-07-30T13:00:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexwarren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alexwarren/32/14002_2.png) [@alexwarren](https://answers.netlify.com/u/alexwarren)\
**Post date:** [July 30, 2020, 1:00pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/1 "2020-07-30T13:00:20Z")

</div>

I’m getting some strange behaviour from this function: remembermore-dashboard.netlify.app/.netlify/functions/submit

(add https:// to the front of that to see what I mean. I can’t make this post with that link in it)

The code is simply:

```auto
exports.handler = function(event) {
    console.log(event);

    return {
        statusCode: 200,
        body: 'Hello world'
    };
};

```

When I run this locally using `netlify dev`, I see the “Hello world” output.

On the live site though, I get an HTTP 200 but an empty body.

I can see from the Function log that the code is indeed executing, but something appears to be truncating the body.

(Side note, when I initially tried to post this, my post failed to appear - probably some spam filter? The topic disappeared and I saw the errors below in the browser console. I could only get this post to appear once I removed the URL)

 ![Screenshot 2020-07-30 at 13.58.03](https://global.discourse-cdn.com/netlify/original/2X/6/6f1ee14f04cbf1f32a4045e215758037cf136c05.jpeg)

---

<div class="post-metadata">

**Author:** ![Scott](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/scott/32/26136_2.png) [@Scott](https://answers.netlify.com/u/Scott)\
**Post date:** [July 30, 2020, 3:14pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/7 "2020-07-30T15:14:16Z")

</div>

Try stringifying your output 🙂

`body: JSON.stringify('hello world')`

---

<div class="post-metadata">

**Author:** ![alexwarren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alexwarren/32/14002_2.png) [@alexwarren](https://answers.netlify.com/u/alexwarren)\
**Post date:** [July 30, 2020, 3:37pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/8 "2020-07-30T15:37:30Z")

</div>

I’m not sure why stringifying the body content would make a difference? The Netlify documentation for functions has them returning ordinary strings as output for the body, and I have that working fine in other repos.

Anyway, I gave it a go, and I’m still seeing the same thing. Blank output when served from `https://remembermore-dashboard.netlify.app/.netlify/functions/submit`, but it works fine when I serve it locally using `netlify dev`.

---

<div class="post-metadata">

**Author:** ![Scott](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/scott/32/26136_2.png) [@Scott](https://answers.netlify.com/u/Scott)\
**Post date:** [July 30, 2020, 4:00pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/9 "2020-07-30T16:00:41Z")

</div>

IIRC and checking the [repo](https://github.com/netlify/netlify-lambda), you’ll also need

`exports.handler = function(event, context, callback)`

---

<div class="post-metadata">

**Author:** ![alexwarren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alexwarren/32/14002_2.png) [@alexwarren](https://answers.netlify.com/u/alexwarren)\
**Post date:** [July 30, 2020, 4:09pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/10 "2020-07-30T16:09:32Z")

</div>

That will have no effect if the function doesn’t use those parameters.

Again, to clarify:

- I know the function is being called on Netlify, because I can see the invocations in the function log - so the `console.log` bit works
- This works as expected locally, I can see the output in both Chrome and curl (whether or not it is output as a JSON string)
- On the Netlify production deployment, I get the HTTP 200 success code, but the body of the response is empty.

---

<div class="post-metadata">

**Author:** ![alexwarren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alexwarren/32/14002_2.png) [@alexwarren](https://answers.netlify.com/u/alexwarren)\
**Post date:** [July 30, 2020, 6:00pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/11 "2020-07-30T18:00:49Z")

</div>

I’ve fixed this now. It was because I was missing the `async` keyword on the function definition.

This works:

```auto
exports.handler = async function(event) {
    console.log(event);

    return {
        statusCode: 200,
        body: 'Hello world'
    };
};

```

Weird that it worked in `netlify dev`, maybe that’s a bug.

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [July 30, 2020, 6:10pm UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/12 "2020-07-30T18:10:52Z")

</div>

hey alex, if you feel like it’s warranted, an issue on this repo would be great:

> **[GitHub - netlify/cli: Netlify Command Line Interface](https://github.com/netlify/cli)**
>
> Netlify Command Line Interface. Contribute to netlify/cli development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![alexwarren](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/alexwarren/32/14002_2.png) [@alexwarren](https://answers.netlify.com/u/alexwarren)\
**Post date:** [July 31, 2020, 8:35am UTC](https://answers.netlify.com/t/no-output-from-lambda-function/19824/13 "2020-07-31T08:35:05Z")

</div>

Thanks, I’ve logged [Function response should have empty body if async keyword is missing · Issue #1047 · netlify/cli · GitHub](https://github.com/netlify/cli/issues/1047)
