API
In a real-world app, we would place all the calls to our backend in a separate api folder. For educational purposes, we just mocked the two API calls that are core to our app, addImage and fetchImages:
/*** src/api/index ***/
export default {
addImage: function(image) {
return new Promise((resolve, reject) => {
setTimeout(()=>{
resolve( '<imgUrl>' );
}, 3000)
})
},
fetchImages: function(user = null){
const images = [
{id: 1, src: '<imgUrl>', user: {pic: '<imgUrl>', name: 'Naia'}},
{id: 2, src: '<imgUrl>', user: {pic: '<imgUrl>',
name: 'Mike_1982'}},
{id: 5, src: '<imgUrl>', user: {pic: '<imgUrl>',
name: 'Sharer1'}},
{id: 3, src: '<imgUrl>', user: {pic: '<imgUrl>', name: 'Naia'}},
{id: 6, src: '<imgUrl>', user: {pic: '<imgUrl>',
name: 'Sharer1'}},
{id: 4, src: '<imgUrl>', user: {pic: '<imgUrl>',
...