Skip to content

Instantly share code, notes, and snippets.

View PowellTravis's full-sized avatar
🎯
Focusing

Travis Powell PowellTravis

🎯
Focusing
  • 17:39 (UTC -06:00)
View GitHub Profile
@PowellTravis
PowellTravis / API Data to MongoDB using Mongoose and Axios.md
Last active November 28, 2023 15:05
Using Mongoose and Axios Together to Upload API Data

BANNER

Using Mongoose and AXIOS to upload APU data to MongoDB

Uploading data using Axios and Mongoose can be hard at first. But when you really understand what you are doing you will be glad you are not reaching out to the API each time someone loads your webpage.

Installing the Packages

  1. Make sure you have nodejs and NPM installed, NPM comes with nodejs

npm install axios mongoose

Using NGINX as a Reverse Proxy for Express.js

If you want to run a reverse proxy using Nginx as your reverse proxy, you can follow along with this document to get it working fast in no time.

In the default config file you are able to remove everything from the file and add in the code below. (/etc/nginx/sites-available/default) What this code below does is it takes the port 5000 on localhost and push it to the root /. Then after that it takes port 4000 and pushes it to /app. But there is some more in there, so what line 1 under location /app does is it rewrites the url to use the domain which is ^ and adds the /app to it with any extention it uses.