Recipe - Food - Nutrition

फ्रीमियम
Verified
द्वारा David | अपडेट किया गया לפני 6 ימים | Food
लोकप्रियता

9.9 / 10

लेटेंसी

1,904ms

सेवा का स्तर

100%

Health Check

N/A

सभी चर्चाओं पर वापस जाएं

Rapid API call in a 'fetch' request?

Rapid account: John Pett
JohnPett
לפני 5 שנים

Hello there!

I’ve only wanted to consume the API calls in React or a front-end framework, so don’t want to use the ‘unirest’ npm module. Is there a way to do it with a ‘fetch’ request? When I do it this way I get an empty object returned and no error:

const headers = new Headers({
“X-RapidAPI-Host”: “spoonacular-recipe-food-nutrition-v1.p.rapidapi.com”,
“X-RapidAPI-Key”: “MY_API_KEY”
})

const options = {
method: “GET”,
headers: headers
};

fetch(‘https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/quickAnswer?q=Gluten+free+brownies’, options)
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(JSON.stringify(myJson));
})
.catch(function(error) {
console.log('There has been a problem with your fetch operation: ', error.message);
});

चर्चा में शामिल हों - नीचे टिप्पणी जोड़ें:

नई टिप्पणियाँ पोस्ट करने के लिए लॉग इन / साइनअप करें