Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/httpDo #2164

Merged
merged 5 commits into from
Sep 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,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