How to send Image src from node js to html?

Viewed 25

I have one query. I am generating a URL when someone enters that URL. With NodeJS, a get request route hits. With that, I am receiving the image URL, and I need to pass the image URL to the src attribute. Can someone guide me? How is it possible? I tried ejs also, but it shows me an error unexpected token '<' in DOCTYPE with this syntax src = "<%= url%>" or also tried src = {{url}} both are not working.

app.get('/viewer/:id', async (req,res)=>{
const v = req.params.id;
const params = {
    KeyConditionExpression: "Id = :s",
    ExpressionAttributeValues: {
        ":s": v
    },
    ProjectionExpression: "Id, #URL, FileName",
    ExpressionAttributeNames: {
        "#URL": "URL"
    },
    TableName: "ar-viewer-table"
}
let data;
docClient.query(params, function (err, fetchedData) {
    if (err) {
        console.log("Error", err);
    } else {
        data = fetchedData
        res.render('viewer.html',{
            url:data.Items.URL
        })   
    }
})

})

0 Answers
Related