Inserting fetch response into a collection

Hello Majd still struggling to understand your last post. I AM SO CLOSE!!. I thought the following made sense, but no chance. Could use your knowledge when you get a chance. hank you.

// Filename: backend/sendEmail.jsw (web modules need to have a .jsw extension)
import { fetch } from ‘wix-fetch’;
import wixData from ‘wix-data’;
// wix-fetch is the API we provide to make https calls in the backend
export function sendOrder(address, zipcode, file) {
return fetch(’ https://api.housecanary.com/v2/property/sales_history ', {
body: JSON.stringify([{ “address”: address, “zipcode”: zipcode }]),
headers: {
Authorization: "Basic xxxxxxxxxxxxxxxxx”
‘Content-Type’: “application/json”,
},
method: ‘post’,
})
.then((result) => result.json())
//.then((result) => console.log(result))
.then((data) => {
console.log(data)
const resultArray = [
title = data[0][‘property/sales_history’].result.apn,
fips = data[0][‘property/sales_history’].result.fips,
event_type = data[0][‘property/sales_history’].result.event_type,
apn = data[0][‘property/sales_history’].result.apn,
grantee1 = data[0][‘property/sales_history’].result.grantee_1,
grantee2 = data[0][‘property/sales_history’].result.grantee_2,
grantor2 = data[0][‘property/sales_history’].result.grantor_2,
record_page = data[0][‘property/sales_history’].result.record_page,
grantor2fore = data[0][‘property/sales_history’].result.grantor_2_forenames,
amount = data[0][‘property/sales_history’].result.amount,
grantee1fore = data[0][‘property/sales_history’].result.grantee_1_forenames,
record_date = data[0][‘property/sales_history’].result.record_date,
grantee2fore = data[0][‘property/sales_history’].result.grantee_2_forenames,
grantor1 = data[0][‘property/sales_history’].result.grantor_1,
record_doc = data[0][‘property/sales_history’].result.record_doc,
record_book = data[0][‘property/sales_history’].result.record_book,
grantor1fore = data[0][‘property/sales_history’].result.grantor_1_forenames
];
let title = title
let fips = fips
let event_type = event_type
let apn = apn;
let grantee1 = grantee1;
let grantee2 = grantee2;
let grantor2 = grantor2;
let record_page = record_page;
let grantor2fore = grantor2fore;
let amount = amount;
let grantee1fore = grantee1fore;
let record_date = record_date;
let grantee2fore = grantee2fore;
let grantor1 = grantor1;
let record_doc = record_doc;
let record_book = record_book;
let grantor1fore = grantor1fore
let toInsert = {
‘title’: title,
‘fips’: fips,
‘event’: event_type,
‘apn’: apn,
‘grantee1’: grantee1,
‘grantee2’: grantee2,
‘grantor2’: grantor2,
‘page’: record_page,
‘grantor2Fore’: grantor2fore,
‘amount’: amount,
‘grantee1Fore’: grantee1fore,
‘date’: record_date,
‘grantee2Fore’: grantee2fore,
‘grantor1’: grantor1,
‘doc’: record_doc,
‘book’: record_book,
‘grantor1Fore’: grantor1fore
}
resultArray.forEach((item) => {
toInsert[item] = item;
wixData.insert(“SalesHistory”, toInsert)
}).then((results) => {
console.log(results); //see if it inserted
})
.catch((err) => {
console.log(err); //see if error occured
});
});
}