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 trial

JavaScript

Killeon Patterson
Killeon Patterson
18,528 Points

undefined usersId, unable to complete get request

Hello,

I'm attempting to retrieve objects from an array in my database. The StoreDetails component is supposed to retrieve the objects from the items array on the store object. The issue appears to be that the route is returning undefined because userId is not being read correctly. I've attempted some resolutions to this issue and have not found a successful one. I fed some code to chatapi, it made some changes to my original code

  • adding the userId in the App.js to be populated during the signin process.
  • It added the userId to local storage (which doesn't seem right for the context of another user being able to access another user's store page)

Either way, that has not worked. Can you see any reason I would get 404 and 304 statuses when I try to get the data? This is the schema that route is suppose to be pulling from

github

_id
665c6f5ebdce18db19ab96a3
name
"Bobby Lee"
username
"bobbylee"
password
"$2a$10$JFJsXZlXoT79Wim722uPI.kwyYV7IOa0OTXWGom1YUKoSCpd1lYv6"
email
"bobbylee@gmail.com"
kind
"user"

store
Object
name
"Brianna's Diner "
description
"Classic Diner"
location
"Bend, Or"

items
Array (1)

0
Object
title
"Salsbury Steak"
description
"Red sauce meatloaf"
price
"18"
quantity
"20"
_id
665c6f98bdce18db19ab96a4

```JS