For the security project Stock Price Checker, do I set up the mongoDB connection? Or is that already set up on the back end and connected to express and I need only add my database connect string to the .env file ( assigned to the variable DB ) ?
In the server.js file an express instance is already instatiated, and I succefully connected to mongodb , and I see starter code in the api.js file for api calls to specific routes, but where do I utilize the base url ? I need hints on this concept…
Typically, setting up the MongoDB connection involves configuring it on the backend for projects like the Stock Price Checker. You’d usually need to ensure MongoDB is installed and running, then connect it to Express using Mongoose or a similar library. Adding your database connection string to the .env file (assigned to DB) is part of configuring this connection securely. Double check the documentation or contact the project maintainers for clarity if unsure.
Thanks, I’ve already established connection with Monggodb atlas using mongoose. I’m not clear on the api call to https://stock-price-checker-proxy.freecodecamp.rocks/. I am unsure of how to plan the design of the connection, particularly, where to use this base url. I understand where to access specific paths ( ex. “/stock-price”) but I am unsure where I connect to the base url as a whole.
So I need to use the request module ? Most of the examples from previous modules use the local host and made up data to insert into mongoDB. When calling a real website it seems like I might have to use the ‘request’ module? and ‘fetch’ ? To call just a specific path is not enough because the base is not my local host? Is that correct?
You can fetch on the backend just as you do on a client.
Current Node versions include fetch, but you can also use libraries if you prefer (Request is deprecated, so I wouldn’t use that Alternative libraries to request).
Not really sure what you mean here?
https://stock-price-checker-proxy.freecodecamp.rocks/ is an API proxy. The “landing page” is just a usage example page, if you hit the actual API endpoint you will get back JSON.
It should be v1, that is the API version and is the endpoint given in the API docs.
As an aside, API versions are used so that if an API introduces breaking changes, it can do a version bump. That way, the old API can live side by side with the new version (until the old is potentially deprecated). It is just a good practice to version an API.