Answer the question
In order to leave comments, you need to log in
How to get photo from api?
I use api gallery.dev.webant.ru/api/photos and I want to display photos from it, I give the path to the photo through media_object to the component but to no avail, I tried to enter contentUrl but the
json error that comes
{
"totalItems": 588,
"itemsPerPage": 30,
"countOfPages": 20,
"data": [
{
"id": 79,
"name": "New image",
"description": "fresh, new image",
"new": true,
"popular": false,
"image": {
"id": 224,
"contentUrl": "5bace356e5e5d387633311.png"
}
},
{
"id": 81,
"name": "rrfwrewqerrew",
"description": "rwrerwrwwr",
"new": true,
"popular": false,
"image": {
"id": 226,
"contentUrl": "5bacee15e9f17619014749.png"
}
},
и тд
}
<template>
<li>
<DxButton
:on-click=" showImageInfo "
class=" button-info img "
:style="{ 'background': ` url( http://gallery.dev.webant.ru/api/media_objects/${ photo.image.id } ) ` }"
/>
</li>
</template>
<script>
import { DxButton } from 'devextreme-vue/button';
export default {
components: { DxButton },
props: {
photo: {
type: Object,
required: true,
default: () => ( {} )
},
showInfo: {
type: Function,
required: true,
default: () => {}
}
},
methods: {
showImageInfo() {
this.showInfo( this.photo );
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question