Error when displaying variable in vector

Asked

Viewed 44 times

1

Good evening guys, I need some help with a JS vector...

When I type this way the same works ok, it displays all messages, but when I put the test variable in place it shows nothing:

var teste = document.getElementById('conversa').innerHTML; 
return {
		"messages":[
			{"_id":"57","text":"oi mae","userId":"54","date":"2016-10-19T13:45:00.000Z"},{"_id":"54","text":"Oi filho","userId":"57","date":"2016-10-19T13:47:00.000Z"},{"_id":"54","text":"Leo","userId":"57","date":"2016-10-19T13:51:00.000Z"},{"_id":"54","text":"...","userId":"57","date":"2016-10-19T13:52:00.000Z"},{"_id":"54","text":"Ha","userId":"57","date":"2016-10-19T13:52:00.000Z"},{"_id":"54","text":"XD","userId":"57","date":"2016-10-19T13:56:00.000Z"},{"_id":"54","text":"...","userId":"57","date":"2016-10-19T13:56:00.000Z"},{"_id":"54","text":"Ahh","userId":"57","date":"2016-10-19T13:57:00.000Z"},{"_id":"54","text":"T","userId":"57","date":"2016-10-19T13:58:00.000Z"},{"_id":"54","text":"F","userId":"57","date":"2016-10-19T13:59:00.000Z"},{"_id":"54","text":"X","userId":"57","date":"2016-10-19T14:02:00.000Z"},{"_id":"54","text":"Kk","userId":"57","date":"2016-10-19T14:03:00.000Z"},{"_id":"54","text":"Xp","userId":"57","date":"2016-10-19T14:06:00.000Z"},{"_id":"54","text":"...","userId":"57","date":"2016-10-19T14:08:00.000Z"},{"_id":"57","text":"ok","userId":"54","date":"2016-10-19T14:08:00.000Z"},{"_id":"54","text":"Jdjjd","userId":"57","date":"2016-10-19T14:09:00.000Z"},{"_id":"54","text":"K","userId":"57","date":"2016-10-19T14:14:00.000Z"},{"_id":"57","text":"leo","userId":"54","date":"2016-10-19T14:14:00.000Z"},{"_id":"57","text":"ke","userId":"54","date":"2016-10-19T14:16:00.000Z"},{"_id":"54","text":"L","userId":"57","date":"2016-10-19T14:16:00.000Z"},{"_id":"57","text":"leo","userId":"54","date":"2016-10-20T16:40:00.000Z"},{"_id":"57","text":"leo","userId":"54","date":"2016-10-20T16:41:00.000Z"},
		]
	  };

You could help me with a solution, I need the data to be dynamic within the "messages" vector... and this test variable is dynamic but when entering inside it shows nothing on the page.

Note: All this content

{"_id":"57","text":"oi mae","userId":"54","date":"2016-10-19T13:45:00.000Z"},{"_id":"54","text":"Oi filho","userId":"57","date":"2016-10-19T13:47:00.000Z"},{"_id":"54","text":"Leo","userId":"57","date":"2016-10-19T13:51:00.000Z"},{"_id":"54","text":"...","userId":"57","date":"2016-10-19T13:52:00.000Z"},{"_id":"54","text":"Ha","userId":"57","date":"2016-10-19T13:52:00.000Z"},{"_id":"54","text":"XD","userId":"57","date":"2016-10-19T13:56:00.000Z"},{"_id":"54","text":"...","userId":"57","date":"2016-10-19T13:56:00.000Z"},{"_id":"54","text":"Ahh","userId":"57","date":"2016-10-19T13:57:00.000Z"},{"_id":"54","text":"T","userId":"57","date":"2016-10-19T13:58:00.000Z"},{"_id":"54","text":"F","userId":"57","date":"2016-10-19T13:59:00.000Z"},{"_id":"54","text":"X","userId":"57","date":"2016-10-19T14:02:00.000Z"},{"_id":"54","text":"Kk","userId":"57","date":"2016-10-19T14:03:00.000Z"},{"_id":"54","text":"Xp","userId":"57","date":"2016-10-19T14:06:00.000Z"},{"_id":"54","text":"...","userId":"57","date":"2016-10-19T14:08:00.000Z"},{"_id":"57","text":"ok","userId":"54","date":"2016-10-19T14:08:00.000Z"},{"_id":"54","text":"Jdjjd","userId":"57","date":"2016-10-19T14:09:00.000Z"},{"_id":"54","text":"K","userId":"57","date":"2016-10-19T14:14:00.000Z"},{"_id":"57","text":"leo","userId":"54","date":"2016-10-19T14:14:00.000Z"},{"_id":"57","text":"ke","userId":"54","date":"2016-10-19T14:16:00.000Z"},{"_id":"54","text":"L","userId":"57","date":"2016-10-19T14:16:00.000Z"},{"_id":"57","text":"leo","userId":"54","date":"2016-10-20T16:40:00.000Z"},{"_id":"57","text":"leo","userId":"54","date":"2016-10-20T16:41:00.000Z"},

Is within the variable teste.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.