No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

2. Getting set up

Duration: 2:00

Get a key for the Dark Sky API

Our weather data comes from the Dark Sky API. In order to use it, you’ll need to request an API key. It’s easy to use, and free for non-commercial projects.

Register for API Key

Verify your API key is working properly

To test that your API Key is working properly, make an HTTP request to the DarkSky API. Update the URL below to replace DARKSKY_API_KEY with your API key. If everything works, you should see the latest weather forecast for New York City.

Copy
https://api.darksky.net/forecast/DARKSKY_API_KEY/40.7720232,-73.9732319

Get the code

We’ve put everything you need for this project into a Git repo. To get started, you’ll need to grab the code and open it in your favorite dev environment. For this codelab, we recommend using Glitch.

Strongly Recommended: Use Glitch to import the repo

Using Glitch is the recommended method for working through this codelab.

  • Open a new browser tab and go to https://glitch.com.
  • If you don’t have an account, you’ll need to sign up.
  • Click New Project, then Clone from Git Repo.
  • Clone https://github.com/googlecodelabs/your-first-pwapp.git and click OK.
  • Once the repo has loaded, edit the .env file, and update it with your DarkSky API key.
  • Click the Show Live button to see the PWA in action.
  • Alternative: Download code & work locally

    If you want to download the code and work locally, you’ll need to have a recent version of Node, and code editor setup and ready to go.

    Download source code

  • Unpack the downloaded zip file.
  • Run npm install to install the dependencies required to run the server.
  • Edit server.js and set your DarkSky API key.
  • Run node server.js to start the server on port 8000.
  • Open a browser tab to http://localhost:8000