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 Building a MEAN Application Going MEAN with Express Mocking Data

Jason Martin
PLUS
Jason Martin
Courses Plus Student 9,316 Points

var todos = require (../../???

If mock is in our main directory then what does ../../ do? for var todos = require('../../mock/todos.json');

2 Answers

This 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.

Jason Martin
Jason Martin
Courses Plus Student 9,316 Points

Great - Thanks clears up my confusion - thank you for taking the time to explain that.

Bryant Feld
seal-mask
.a{fill-rule:evenodd;}techdegree
Bryant Feld
Full Stack JavaScript Techdegree Student 26,144 Points

you 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