A
A
Alexey Kisilev2019-07-12 18:34:15
JavaScript
Alexey Kisilev, 2019-07-12 18:34:15

How to display image in browser using Js?

There is a database that stores the path to the image. After using Express js, I take the paths and save them to an array. After I start the server and want to display the image data in the browser. How to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
r_mustang, 2019-07-12
@Reshk_0

const array = ['1.jpg', '2.jpg'] // массив с картинками

app.get('/', function (req, res) {
  const response = array.map(item => `<img src="${item}" />`).join('')
  res.send(response)
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question