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 trialDuy Khanh
Courses Plus Student 4,911 PointsWhy we need process.argv.slice(2) ?
Anyone can explain about process.argv.slice(2)? Why we need to slice and why the param is 2 ?
1 Answer
Steven Parker
231,236 PointsThe "argv" array contains everything given on the command line. The first item (argv[0]) will be the path to node itself, and the second item (argv[1]) will be the path to your script code.
So a slice starting at 2 will discard both of those and return everything else that was typed on the command line. These are the arguments that will be used to construct the API query string.
Duy Khanh
Courses Plus Student 4,911 PointsDuy Khanh
Courses Plus Student 4,911 Pointsyeah thanks so lot for answer :D
Uche Onuekwusi
18,070 PointsUche Onuekwusi
18,070 PointsHI STEVEN please can you explain how to construct the api query string
Steven Parker
231,236 PointsSteven Parker
231,236 PointsThat part is covered in the video. And for this particular API, it's just a URL.