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 trialJason Martin
Courses Plus Student 9,316 Pointsvar todos = require (../../???
If mock is in our main directory then what does ../../ do? for var todos = require('../../mock/todos.json');
2 Answers
tobiaskrause
9,160 PointsThis is a relative path.
../../ means "two folders over the current folder... doesn't matter how they are named".
The index.js (the file with the ../../ path) is located in mean-todo/src/api/index.js
while the todo.json was in
mean-todo/mock/todo.json
. So
So we move two folders up (from the location of index.js)..so we are in the folder "mean-todo" and then we move to the folder "mock" where the todo.json is located.
Bryant Feld
Full Stack JavaScript Techdegree Student 26,144 Pointsyou cannot make a get request for files that are not being served, the express server is set up to serve from "public" so you have to put the mock folder in the public folder and change the path in index.js accordingly, I think this was an uncaught glitch in the course
Jason Martin
Courses Plus Student 9,316 PointsJason Martin
Courses Plus Student 9,316 PointsGreat - Thanks clears up my confusion - thank you for taking the time to explain that.