const axios = require('axios'); async function istock(q) { try { if (!q) throw new Error('Query is required'); const { data } = await axios.get(`https://www.istockphoto.com/en/search/2/image-film?phrase=${q}&page=${Math.floor(Math.random() * 100) + 1}`, { headers: { accept: 'application/json' } }); return data.gallery.assets.map(res => ({ caption: res.caption, type: res.mediaType, orientation: res.orientation, quality: res.quality, artist: res.artist, uploadDate: res.uploadDate, thumbnailUrl: res.thumbUrl, url: `https://www.istockphoto.com${res.landingUrl}` })); } catch (error) { throw new Error(error.message); } } // Usage: const resp = await istock('field'); console.log(resp);