help icon indicating copy to clipboard operation
help copied to clipboard

How to send Image src from node js to html?

Open deep9888 opened this issue 3 years ago • 1 comments

Details

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.

Node.js version

v16.14.2

Example code

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
        })   
    }
})
})

Operating system

Windows

Scope

code

Module and version

Not applicable.

deep9888 avatar Sep 13 '22 05:09 deep9888

Probably you need to mention the response content-type to your browser

siddiq-rehman avatar Oct 03 '22 19:10 siddiq-rehman

There has been no activity on this issue for 11 months. The help repository works best when sustained engagement moves conversation forward. The issue will be closed in 1 month. If you are still experiencing this issue on the latest supported versions of Node.js, please leave a comment.

github-actions[bot] avatar Nov 27 '23 01:11 github-actions[bot]

Closing after no activity on this issue for 12 months.

github-actions[bot] avatar Dec 28 '23 01:12 github-actions[bot]