I have a local express server that serves a json file. I also have many image files inside a local folder. The image paths are parts of the json object which I want to show in my DOM. However I get string representation of these image paths as part of response which I can't use. What is the best way to server local images to the frontend from a local server.
My server side config:
app.use(express.static(path.join(__dirname, 'public')))
app.use(express.static(path.join(__dirname, 'server/img')))
My JSON file
{
"Images": [{
"title": "First Block",
"images": ["server/img/bijay.jpg", "server/img/dance.png", "server/img/ocean.jpg"]
}, {obj2}, {obj3}, {obj4}]
}
My client-side code to print image
<ul>
<li ng-repeat="obj in objArray"><img ng-src="{{obj.images[0]}}"></li>
</ul>
// just testing first image
My folder structure:
Images are inside the img folder. not shown here to save space