Build a travel app. Utilize multiple APIs to present a user with all they need to know about their trip.
The APIs that we are going to use in this implementations are:
Remember that once you clone, you will still need to install everything:
cd
into your new folder and run:
npm install
You can run the project in development
or production
mode by using the following commands:
- Development mode:
npm run build-dev
- Production mode:
npm run build-prod
- Run tests:
npm run test
Note: scripts can be found in package.json
The GeoNames geographical database covers all countries and contains over eleven million placenames.
Sign up here and get your API key.
Here is the documentation for GeoNames Search Webservice.
Weather API you can retrieve current weather observations from over 47,000 live weather stations, historical weather data for the past 10 years from our archive of more than 120,000 stations, and highly localized weather forecasts for any point on the globe using the world's most trusted weather models.
Sign up here and get your API key.
Here is the documentation for Current Weather API.
RESTful interface for searching and retrieving free images and videos released under the Pixabay License.
Sign up here and get your API key.
Here is the documentation for Current Weather API.
let API_KEY = PIXABAY_API_KEY;
let URL = "https://pixabay.com/api/?key="+API_KEY+"&q="+encodeURIComponent('red roses');
$.getJSON(URL, function(data){
if (parseInt(data.totalHits) > 0)
$.each(data.hits, function(i, hit){ console.log(hit.pageURL); });
else
console.log('No hits');
});
Environment variables are pretty much like normal variables in that they have a name and hold a value, but these variables only belong to your system and won't be visible when you push to a different environment like Github.
- Use npm or yarn to install the dotenv package
npm install dotenv
. This will allow us to use environment variables we set in a new file - Create a new
.env
file in the root of your project - Go to your .gitignore file and add
.env
- this will make sure that we don't push our environment variables to Github! If you forget this step, all of the work we did to protect our API keys was pointless. - Fill the .env file with your API keys like this:
GEONAMES_USERNAME=**************************
WEATHERBIT_API_KEY=**************************
PIXABAY_API_KEY=**************************
- Add this code to the very top of your server/index.js file:
const dotenv = require('dotenv');
dotenv.config();
A great step to take with your finished project would be to deploy it!
Checkout Netlify or Heroku for some really intuitive free hosting options.