-1

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

tesa
  • 1
  • 1

2 Answers2

0

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.

leontkp
  • 50
  • 5
0

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

tesa
  • 1
  • 1