Thanks for the response Yisrael, and sorry about the screenshots! Didn’t cross my mind because there was an api key. unfortunately fixing the await still doesnt work ![]()
//backend
import { fetch } from 'wix-fetch';
export function getData(scannedCode) {
fetch("https://api.airtable.com/v0/appMaPkpcKSDYejii/Branch%20Mode?filterByFormula={Location}='" + scannedCode + "'&api_key=keyCMA7U7eeqjRSzE", { "method": "get" })
.then((httpResponse) => {
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject("Fetch did not succeed");
}
})
.then(json => console.log(json.records))
.catch(err => console.log(err));
}
//homepage
import { getData } from 'backend/key.jsw';
$w.onReady(function ()
{});
export function button1_click(event) {
let scannedCode = $w('#searchCode').value
return getData(scannedCode)
.then(response => {
console.log(response); //undefined
})
}
try searching TEST33491 for scannedcode