I'm getting a string from the database that has base64 encoded Image like this res.send(user.img)
. here is what I'm getting:
All I want is to get this string:
The string that I'm trying to get
But here is what happens when I try to specify the value that I need like this res.send(user.img.data)
:
data transforms into crazy gibbersih
Crazy, right? I just want to get that string and for it to be normal text and not gibberish. Please, help.
Here is how the object looks in the DB (notice how it looks properly here):
Here is the fetch:
app.post("/getImage", (req, res)=>{
User.findOne({ login: "name" })
.then((user) => res.send(user.img.data))
.catch((error) => {
console.log(error);
res.send(500)
});
})
Here is what i'm doing in Postman: