Inserting fetch response into a collection

Try this out, you have some syntax errors that I fixed a bit.

 
// 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 toInsert = {};
                  resultArray.forEach((item) => {     
                         toInsert[item] = item; 
                  }); 
                  
                  wixData.insert("SalesHistory", toInsert )
                    .then((inserted)=> {
                    console.log('inserted: ', inserted);
                    })
    }).then((results) => {
                    console.log(results); //see if it inserted
    })
    .catch((err) => {
                    console.log(err); //see if error occured 
    });
  });
}