Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRichard Preske
Courses Plus Student 4,356 PointsConverting a basic AJAX program
I'm trying to convert one of the projects in the basic AJAX course. I replaced the XHR requests with fetch and promise all and I get no errors. I'm having trouble, however, displaying the data - rooms full, empty and employees in, out. Any suggestions?
1 Answer
Steven Parker
231,275 PointsI see a few issues:
- the data items are arrays of objects, and don't have a "message" property (lines 13 & 14)
- the properties of an array ("for in") are just indexes use the values instead ("for of") (lines 36 & 58)
- the "name" is a property of the item ("property") and not the array ("data") (lines 42 & 64)
Richard Preske
Courses Plus Student 4,356 PointsRichard Preske
Courses Plus Student 4,356 PointsThanks, I'll check it out. The message property does work though displaying the array of objects when I logged to console - lines 13 and 14. Why?
Got it figured out, thanks again!
Steven Parker
231,275 PointsSteven Parker
231,275 PointsAttempting to get a 'message" attribute from an array should give you "undefined". If you see something else, what's the complete code in the callback at that point?