converting JSON to wix-fetch

Hi everyone;

i am struggling with the syntax for taking a standard node.js API from the internet and putting it into wix-fetch. I’ve read all the articles and looked at examples and youtube but can’t seem to quite get the syntax right for doing this when a key is involved (all the good examples I find don’t have keys). Here is the code from the node.js with a sample key:

const rp = require(‘request-promise’);
const requestOptions = {
method: ‘GET’,
uri: ‘https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest’,
qs: {
‘id’: ‘1’
},
headers: {
‘X-CMC_PRO_API_KEY’: ‘b54bcf4d-1bca-4e8e-9a24-22ff2c3d462c’
},
json: true,
gzip: true
};

rp(requestOptions).then(response => {
console.log(‘API call response:’, response);
}).catch((err) => {
console.log(‘API call error:’, err.message);
});

So basically I need help changing this to the wix-fetch syntax. Thank you all in advance!

Hi.

You can refer to our API here for the correct documentation:
https://www.wix.com/corvid/reference/wix-fetch.html
Corvid: Accessing Third-Party Services with the Fetch API

You can also check out this Forum discussion : https://www.wix.com/corvid/forum/community-discussion/wix-fetch-typeerror-failed-to-fetch

Good luck!

Did you ever figure this out?

I’m trying to do something similar following this old guide:
https://www.dunebook. com/create-a-cryptocurrency-price-update-website-using-wix-code/