Cannot return from backend

Hello guys, I need help.
Everything in backend works perfectly, I successfully retrieved the data I want.
but I couldn’t pass the retrieved data from backend (key.jsw) to HOME page using return (see line 8)


In the HOME page it says undefined line 10.

where am I doing wrong?
thanks in advance

You should use either await, or .then() - not both together.

These lines should be without await:

return fetch(...)
getData(scannedCode)

Please do not post code with screenshots, please use code blocks.

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 :frowning:

//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