help
help copied to clipboard
How to send Image src from node js to html?
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.
Probably you need to mention the response content-type to your browser
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.
Closing after no activity on this issue for 12 months.