Skip to content

Commit

Permalink
Merge pull request #2164 from austince/docs/http-do
Browse files Browse the repository at this point in the history
docs/httpDo
  • Loading branch information
lmccart authored Sep 18, 2017
2 parents 7c70a38 + 2591538 commit fd7fa9f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,56 @@ p5.prototype.httpPost = function () {
* @param {function} [errorCallback] function to be executed if
* there is an error, response is passed
* in as first argument
*
*
* @example
* <div>
* <code>
* // Examples use USGS Earthquake API:
* // https://earthquake.usgs.gov/fdsnws/event/1/#methods
*
* // displays an animation of all USGS earthquakes
* var earthquakes;
* var eqFeatureIndex = 0;
*
* function preload() {
* var url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson';
* httpDo(url,
* {
* method: 'GET',
* // Other Request options, like special headers for apis
* headers: { authorization: 'Bearer secretKey' }
* },
* function(res) {
* earthquakes = res;
* });
* }
*
* function draw() {
* // wait until the data is loaded
* if (!earthquakes || !earthquakes.features[eqFeatureIndex]) {
* return;
* }
* clear();
*
* var feature = earthquakes.features[eqFeatureIndex];
* var mag = feature.properties.mag;
* var rad = mag / 11 * ((width + height) / 2);
* fill(255, 0, 0, 100);
* ellipse(
* width / 2 + random(-2, 2),
* height / 2 + random(-2, 2),
* rad, rad
* );
*
* if (eqFeatureIndex >= earthquakes.features.length) {
* eqFeatureIndex = 0;
* } else {
* eqFeatureIndex += 1;
* }
* }
* </code>
* </div>
*/

/**
Expand Down

0 comments on commit fd7fa9f

Please sign in to comment.