Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import axios from 'axios'; import config from '../../../config/config'; async function getProductImages(productCode, imageHubHostAddress) { try { const dbUrl = `${imageHubHostAddress}/api/images/${productCode}`; let url = dbUrl || config.beetranslateHost; url = url.endsWith('/') ? url.slice(0, -1) : url; const response = await axios.get(url); let productImages = []; if (response && response.status === 200 && response.data) { productImages = response.data.images.map((image) => ({ url: `${imageHubHostAddress}${image.url}`, description: image.description, tags: response.data.tags, })); } return productImages; } catch (err) { const getProductImagesError = err.response && err.response.data && err.response.data; console.log(getProductImagesError || err); return []; } } export default getProductImages; |