DEV Community

sm-a
sm-a

Posted on

1

How I use Axios with nodeJS and expressjs? I get "undefined" back. What I make wrong?

I only want to receive a JSON response via GET. Unfortunately I just get an "undefined" when I execute the code. The URL is correct. If I call the URL directly with the web browser I get a JSON back.

What I do wrong?

Here my Code:

try {
axios.get("here-my-url")
.then(data => res.status(200).send(data))
.catch(err => res.send(err));
} catch(err) {
console.error("ERROR", err);
}
view raw test.js hosted with ❤ by GitHub

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay