0

I am trying to get a JSON from https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY&query=ketchup and do something with it by storing it into a variable. I used Node and Express in my work. Can anyone please tell me how to. Very much appreciated, Thanks.

2
  • Can you show your code? Please review this question on how to do a minimum reproducible example, for a better experience to help you. stackoverflow.com/help/minimal-reproducible-example Commented Jun 14, 2020 at 5:49
  • you can use, axios or got or SuperAgent or Request or HTTP-the Standard Library in nodejs Commented Jun 14, 2020 at 6:41

1 Answer 1

1

I asume that your server is working and fetching data correctly. Then you can use something like that:

async function getData() {
  return fetch('https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY&query=ketchup')
    .then(response => response.json())
}

getData()
  .then(data => console.log(data))

Like zinkn say here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.