Data-Wrangling-with-JavaScript / Chapter-3

Code examples for Chapter 3 of Data Wrangling with JavaScript
http://bit.ly/2t2cJu2
MIT License
10 stars 4 forks source link

Need to limit search results for listing-3.12 to avoid "400 Error" #4

Closed sestaton closed 5 years ago

sestaton commented 5 years ago

If you run listing-3.12.js as is you'll get:

{ StatusCodeError: 400 - "Error 400: Bad Request\n\n20160 matching events exceeds search limit of 20000. Modify the search to match fewer events.\n\nUsage details are available from https://earthquake.usgs.gov/fdsnws/event/1\n\nRequest:\n/fdsnws/event/1/query.csv?starttime=2017-01-01&endtime=2017-03-02\n\nRequest Submitted:\n2019-01-23T22:45:30+00:00\n\nService version:\n1.7.0"

This is because the API has a defined limit on the number of items that can be returned (20k). If we limit the number of items in the request it will avoid the issue, and this can be done by changing the URL on line 4 to:

const url = "https://earthquake.usgs.gov/fdsnws/event/1/query.csv?starttime=2017-01-01&endtime=2017-03-02&limit=20000";

I could submit a PR if that would help but it's just a one line fix.

Hope this helps.

ashleydavis commented 5 years ago

Hey thanks for reporting this issue! If you submit a PR that would definitely save me some time!

On Fri, 25 Jan 2019, 11:44 Evan Staton notifications@github.com wrote:

If you run listing-3.12.js as is you'll get:

{ StatusCodeError: 400 - "Error 400: Bad Request\n\n20160 matching events exceeds search limit of 20000. Modify the search to match fewer events.\n\nUsage details are available from https://earthquake.usgs.gov/fdsnws/event/1\n\nRequest:\n/fdsnws/event/1/query.csv?starttime=2017-01-01&endtime=2017-03-02\n\nRequest Submitted:\n2019-01-23T22:45:30+00:00\n\nService version:\n1.7.0"

This is because the API has a defined limit https://earthquake.usgs.gov/fdsnws/event/1/ on the number of items that can be returned (20k). If we limit the number of items in the request it will avoid the issue, and this can be done by changing the URL on line 4 to:

const url = "https://earthquake.usgs.gov/fdsnws/event/1/query.csv?starttime=2017-01-01&endtime=2017-03-02&limit=20000";

I could submit a PR if that would help but it's just a one line fix.

Hope this helps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Data-Wrangling-with-JavaScript/Chapter-3/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmJ5l2R6Wij7Ydq0fS_K7zU02WoLM8fks5vGmGHgaJpZM4aSCyJ .

sestaton commented 5 years ago

Will do!

On Thu, Jan 24, 2019, 6:09 PM Ashley Davis <notifications@github.com wrote:

Hey thanks for reporting this issue! If you submit a PR that would definitely save me some time!

On Fri, 25 Jan 2019, 11:44 Evan Staton notifications@github.com wrote:

If you run listing-3.12.js as is you'll get:

{ StatusCodeError: 400 - "Error 400: Bad Request\n\n20160 matching events exceeds search limit of 20000. Modify the search to match fewer events.\n\nUsage details are available from https://earthquake.usgs.gov/fdsnws/event/1\n\nRequest:\n/fdsnws/event/1/query.csv?starttime=2017-01-01&endtime=2017-03-02\n\nRequest Submitted:\n2019-01-23T22:45:30+00:00\n\nService version:\n1.7.0"

This is because the API has a defined limit https://earthquake.usgs.gov/fdsnws/event/1/ on the number of items that can be returned (20k). If we limit the number of items in the request it will avoid the issue, and this can be done by changing the URL on line 4 to:

const url = " https://earthquake.usgs.gov/fdsnws/event/1/query.csv?starttime=2017-01-01&endtime=2017-03-02&limit=20000 ";

I could submit a PR if that would help but it's just a one line fix.

Hope this helps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Data-Wrangling-with-JavaScript/Chapter-3/issues/4, or mute the thread < https://github.com/notifications/unsubscribe-auth/AAmJ5l2R6Wij7Ydq0fS_K7zU02WoLM8fks5vGmGHgaJpZM4aSCyJ

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Data-Wrangling-with-JavaScript/Chapter-3/issues/4#issuecomment-457429724, or mute the thread https://github.com/notifications/unsubscribe-auth/ABaM4PVBSDZLIxt6biq1tkP-lS7Fj6j2ks5vGmdBgaJpZM4aSCyJ .