Few lines of code needed, properly parse JSON API response with Wix fetch
Budget: $10 – $30 USD
I have both a functional front end and back end for my API call from the Wix Fetch API to the Airtable API.. I am able to retrieve only the Cryptocurrency "Name" field currently.. I am getting errors when I try to parse the other fields like the Market cap data and current market price which are the most important.
I need a couple lines of code I am assuming to be added here that can help me retrieve the Current Market data from the JSON response. I am providing both the code for the Wix backend and front end and also a sample of the json API response message. Please let me know how much you charge for this work..
Wix front end:
import wixWindow from 'wix-window';
$w.onReady(function() {});
import {funcQueryAirtableData} from 'backend/airTableGet.jsw';
export function button1_click(event) {
funcQueryAirtableData()
.then((json) => {
console.log(json);
$w('#coinName').text = String(json.fields.Name).toString();
}
);
}
Wix back end:
import {fetch} from 'wix-fetch';
export async function funcQueryAirtableData(tableName,ColumnName,ColumnValue){
const keyname = "XXXXXXXXXXXXXXXXX" API KEY MASKED FOR SECURITY
const basename = "appBtsEGwlDw8btW5"
const tablename = "Coins"
let record_id = "rec4no8twmDNJzJp5"
let fetchString = 'https://api.airtable.com/v0/' +basename+"/"+tablename+"/"+record_id+"?filterByFormula="+"&api_key="+keyname;
return await fetch(fetchString, {
method: 'get'}
)
.then( (httpResponse) => {
if (httpResponse.ok) {
console.log (httpResponse);
return httpResponse.json();
}
else{
console.log (httpResponse);
return httpResponse.json();
}
} );
}
WIX JSON RESPONSE
{
"id": "rec4no8twmDNJzJp5",
"fields": {
"Name": "Litecoin",
"Id": "litecoin",
"Symbol": "ltc",
"Image": "https://assets.coingecko.com/coins/images/2/large/litecoin.png?1547033580",
"Current price": 136.42,
"Market cap": 9479294263,
"Market cap rank": 19,
"Fully diluted valuation": 11442307901,
"Total volume": 961368520,
"High 24h": 139.37
},
"createdTime": "2022-02-07T21:20:58.000Z"
}
I need a couple lines of code I am assuming to be added here that can help me retrieve the Current Market data from the JSON response. I am providing both the code for the Wix backend and front end and also a sample of the json API response message. Please let me know how much you charge for this work..
Wix front end:
import wixWindow from 'wix-window';
$w.onReady(function() {});
import {funcQueryAirtableData} from 'backend/airTableGet.jsw';
export function button1_click(event) {
funcQueryAirtableData()
.then((json) => {
console.log(json);
$w('#coinName').text = String(json.fields.Name).toString();
}
);
}
Wix back end:
import {fetch} from 'wix-fetch';
export async function funcQueryAirtableData(tableName,ColumnName,ColumnValue){
const keyname = "XXXXXXXXXXXXXXXXX" API KEY MASKED FOR SECURITY
const basename = "appBtsEGwlDw8btW5"
const tablename = "Coins"
let record_id = "rec4no8twmDNJzJp5"
let fetchString = 'https://api.airtable.com/v0/' +basename+"/"+tablename+"/"+record_id+"?filterByFormula="+"&api_key="+keyname;
return await fetch(fetchString, {
method: 'get'}
)
.then( (httpResponse) => {
if (httpResponse.ok) {
console.log (httpResponse);
return httpResponse.json();
}
else{
console.log (httpResponse);
return httpResponse.json();
}
} );
}
WIX JSON RESPONSE
{
"id": "rec4no8twmDNJzJp5",
"fields": {
"Name": "Litecoin",
"Id": "litecoin",
"Symbol": "ltc",
"Image": "https://assets.coingecko.com/coins/images/2/large/litecoin.png?1547033580",
"Current price": 136.42,
"Market cap": 9479294263,
"Market cap rank": 19,
"Fully diluted valuation": 11442307901,
"Total volume": 961368520,
"High 24h": 139.37
},
"createdTime": "2022-02-07T21:20:58.000Z"
}