How can I use JavaScript to fetch images from Airtable and transfer them to WordPress using their APIs?

Looking to automate retrieving images from Airtable and updating empty image fields in WordPress posts with JavaScript.

const airtableHandler = new Airtable({ apiToken: 'YOUR_NEW_API_TOKEN' }).base('YOUR_NEW_BASE_ID');

async function retrieveImages() {
  try {
    const imageRecords = await airtableHandler('ImageCollection').select({ maxRecords: 5, view: 'DefaultView' }).firstPage();
    console.log(imageRecords);
  } catch (error) {
    console.error('Error fetching images:', error);
  }
}

async function pushToWordPress(recordId) {
  try {
    const record = await airtableHandler('ImageCollection').find(recordId);
    // Insert WordPress API logic here to upload image
    console.log(`Processed image for record: ${record.id}`);
  } catch (err) {
    console.error('Error updating WordPress media:', err);
  }
}

retrieveImages();