Axios POST not working with lambda functions

I’m curious to know why this isn’t working on Netlify but it works correctly with express wrapped in serverless-http locally. I’m confused because I’ve used axios to post on Netlify before.

const axios = require("axios").default;
const action = async (body) => {

    const alert = await, {username: `Name`, content:`Test message`});
    console.log("Alert Sent!");
module.exports = action;

Any help is greatly appreciated.

What’s the error that you get? The latest version of Axios is currently broken:

And so it the version before that:

I rolled it back and it still didn’t work. Then I noticed that I needed an await. I was passing the body to the action from another file like this:
const alert = action(body);

But it needed the await like this:
const alert = await action(body);

When I added it during testing before, VScode automatically changed my require when I did a filename change, so it didn’t work during that test. I’m good to go now! Thank you.

Hi @Ladger :wave:t6: , welcome to the forums! We’re so glad you’re here. (; :netliconfetti: Glad to see that your Axios is working as intended. We appreciate the feedback on what went wrong as this will help other users who experience similar issues in the future debug. Happy building. :rocket: