tesa
tesa

Reputation: 1

Trouble displaying data from MongoDb by using js/express.js,

I have a hard time displaying data from my MongoDB to my frontpage. I can see that I get the right number of items in my collection but it tells me [object Object] when I try to display the chosen data. Can anyone help? Thank you Code for getting data from the collection "title"

Call for displaying the 1 element in the title array

What the browser tells me

Upvotes: -1

Views: 27

Answers (2)

tesa
tesa

Reputation: 1

Thank you! I thought I had tried that but nope. Now it works:) Have a good day

Upvotes: 0

leontkp
leontkp

Reputation: 60

You are trying to display a whole object which results in [object Object]. You have to give your HTML a string like result[0].title (assuming you have a field title in your object)

You can also display the whole object with JSON.stringify(result[0]) in JS.

Upvotes: 0

Related Questions