Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit 351224a

Browse files
Trevor MooreTrevor Moore
authored andcommitted
Response fix after the API update.
1 parent 09602b4 commit 351224a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

client/Messaging.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ function initApp() {
146146
promise.done(response => {
147147

148148
// if messages are returned, add them to the chat box.
149-
if (response.length > 0) {
149+
if (response.data.length > 0) {
150150

151151
// get the latest id
152-
const recent = response[response.length - 1].id;
152+
const recent = response.data[response.data.length - 1].id;
153153
console.log('recent:', recent, 'top index:', App.state.highIndex);
154154
if (recent > App.state.highIndex) {
155155

156156
// update the app state
157157
App.state.highIndex = recent;
158158

159159
// append the new messages
160-
App.dom.appendMessagesToChat(response);
160+
App.dom.appendMessagesToChat(response.data);
161161
}
162162
}
163163
});
@@ -169,14 +169,14 @@ function initApp() {
169169
promise.done(response => {
170170

171171
// if results were returned add them to the page.
172-
if (response.length > 0) {
172+
if (response.data.length > 0) {
173173
if (App.state.highIndex === 0) {
174174

175175
// if this is the first call, set the initial highest index
176-
App.state.highIndex = response[0].id;
176+
App.state.highIndex = response.data[0].id;
177177
console.log(App.state.highIndex);
178178
}
179-
App.dom.prependMessagesToChat(response);
179+
App.dom.prependMessagesToChat(response.data);
180180
} else {
181181

182182
// assume there are no older messages and disable the button.

0 commit comments

Comments
 (0)