@replit/database db.get returning [object Object] on json

42 views Asked by At

I'm trying to use @replit/database for my backend, couldn't get it to display anything other than [object Object]

This is the code that I have

const Database = require("@replit/database")
const db = new Database()
app.get("/click", (req, res) => {
    num = db.get("num").then(value => {})
  res.send(JSON.stringify({num: num}))
});

Expected Output: A number that was previously saved Output: object object

Is there any way I can fix this?

1

There are 1 answers

0
AmirparsaDD On

Try JSON.stringify({ "num": num }) or change the key to something else like number