Created
November 27, 2017 20:42
-
-
Save thefln/8f5d2b94b504e141d3730b659437f34f to your computer and use it in GitHub Desktop.
component.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pages/index.vue | |
| <script> | |
| import axios from 'axios' | |
| import SmallProduct from '~/components/SmallProduct.vue' | |
| export default { | |
| components: {SmallProduct}, | |
| async asyncData ({env, params}) { | |
| let {data} = await axios.get(`${env.cockpit.apiUrl}/collections/get/Product?token=${env.cockpit.apiToken}`) | |
| let products = await Promise.all(await data.map(async (p) => { | |
| let result = await axios.post(`${env.cockpit.apiUrl}/mediamanager/thumbnails?token=${env.cockpit.apiToken}`, { | |
| images: [p.Image], | |
| w: 300, | |
| h: 300, | |
| options: { | |
| quality: 80, | |
| mode: 'resize' | |
| } | |
| }) | |
| p.ThumbUrl = `${env.cockpit.baseUrl}${result.data[p.Image]}` | |
| return p | |
| })) | |
| return { | |
| products | |
| } | |
| } | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment