IMPORTANT! Working w/Exoplanet Explorer
What is this?
You'll be working with a stripped down version of the Exoplanet Explorer to complete all of the programming quizzes for the rest of the course. So, you need to install it.
Installation
Instructions: (this will also download polymer starter kit and install it
git clone https://github.com/udacity/exoplanet-explorer.git
cd exoplanet-explorer
npm install -g gulp bower
npm install && bower install -f polymer-starter-kit
gulp serve
clone branch
git clone <git-url> - b <branch-name>
I built the Exoplanet Explorer from the PolymerStarter Kit. I'm copying most of the rest of these instructions from the README written by the Polymer team. If you ever need help, check out the README.
Clone the repo first (for everyone)
Here's thelink to the repo.
You should be on thexhr-start
branch. If not, thengit checkout xhr-start
orgit checkout origin xhr-start
.
Quick-start (for experienced users)
With Node.js installed, run the following one liner from the root of your Exoplanet Explorer download:
npm install -g gulp bower && npm install&& bower install
Prerequisites (for everyone)
The full starter kit requires the following major dependencies:
- Node.js, used to run JavaScript tools from the command line.
- npm, the node package manager, installed with Node.js and used to install Node.js packages.
- gulp, a Node.js-based build tool.
- bower, a Node.js-based package manager used to install front-end packages (like Polymer).
To install dependencies:
1) Check your Node.js version.
node --version
The version should be at or above 0.12.x.
2) If you don't have Node.js installed, or you have a lower version, go tonodejs.organd click on the big green Install button.
3) Installgulp
andbower
globally.
npm install -g gulp bower
This lets you rungulp
andbower
from the command line.
4) Install the starter kit's localnpm
andbower
dependencies.
cd exoplanet-explorer && npm install&& bower install
This installs the element sets (Paper, Iron, Platinum) and tools the starter kit requires to build and serve apps.
NOTE! INSTALLATION MAY TAKE A LONG TIME!There are many dependencies to download and install.
Post-Installation and Workflow
For every quiz, you'll be given a branch to checkout. You can always find it in the instructor notes. All of your work will be done in:
app/scripts/app.js
Serve / watch
gulp serve
This outputs an IP address you can use to locally test and another that can be used on devices connected to your network.
It's recommended to use Chrome, as non-vulcanized Polymer projects will load fastest on Chrome.
Build & Vulcanize
gulp
Build and optimize the current project, ready for deployment. This includes linting as well as vulcanization, image, script, stylesheet and HTML optimization and minification.
Troubleshooting
Seethis bugif you get the following error from Gyp:
"Error: self signed certificate in certificate chain"
11. Quiz: Wrap an XHR
Instructions
- If you haven't already, read this and follow the instructions on working with the Exoplanet Explorer repo.
- Checkout the
xhr-start
branch and navigate toapp/scripts/app.js
. - Wrap the XHR in a Promise in the
get()
function. See XHR documentation for more information. - Resolve on load and reject on error.
- If the XHR resolves, use
addSearchHeader()
to add the search header to the page. - If the XHR fails,
console.log()
the error and pass'unknown'
toaddSearchHeader()
.
12. Web Technologies
Issues with jQuery Promises:
- 10 June 2016 update! With the 3.0 release, jQuery promises now satisfy Promises/A+ compliance!
- You're Missing the Point of Promises - Domenic Denicola (Pre-jQuery 3.0)
- jQuery Deferred Broken - Valerio Gheri (Pre-jQuery 3.0)
Q Style Promises
- They're an implementation of the Promises/A+ spec.
- $q service Documentation.
Browser Implementation
APIs that Use Promises
13. Quiz: Fetch API
Instructions
- If you haven't already, read this and follow the instructions on working with the Exoplanet Explorer repo .
- Checkout the
fetch-start
branch and navigate toapp/scripts/app.js
. - Rewrite
get
with the Fetch API: https://davidwalsh.name/fetch - Finish the
getJSON()
method, which should take a URL and return the parsed JSON response.getJSON()
needs to return a Promise!
- Test by logging the response and by passing the query string from
getJSON()
toaddSearchHeader()
. - Handle errors by passing
'unknown'
toaddSearchHeader()
and logging them.
Fetch API Walkthrough
Checkout thefetch-solution
branch to see my code.