Skip to content

Commit

Permalink
feat(request): adds option to return the raw fetch response
Browse files Browse the repository at this point in the history
request() now accepts a new rawResponse boolean option to indicate that it should return the fetch
response directly to the client.
This is useful for piping the response to a stream.

AFFECTS PACKAGES:
@esri/arcgis-rest-auth
@esri/arcgis-rest-feature-service-admin
@esri/arcgis-rest-feature-service
@esri/arcgis-rest-geocoder
@esri/arcgis-rest-sharing
stream-response-to-file

ISSUES CLOSED: #462
  • Loading branch information
tomwayson committed Feb 15, 2019
1 parent b2e5a4d commit 6fb7c79
Show file tree
Hide file tree
Showing 16 changed files with 288 additions and 186 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Some useful commands include:

* `npm test` runs _all_ the tests and confirms the API is functioning as expected.
* There is also a `Debug Node Tests` configuration in the `.vscode/launch.json` which will run the Node tests in the VS Code debugger.
* `npm run docs:serve` will run the documentation site locally at http://localhost:3000
* `npm run docs:serve` will run the documentation site locally at http://localhost:3000/arcgis-rest-js/
* `npm run build` will created UMD bundles for _all_ the packages
* `npm run dev -- <esm|node|umd> <glob>` will re-run the specified build type anytime the source code changes. Example: `npm run dev -- umd @esri/*`

Expand Down
7 changes: 7 additions & 0 deletions demos/stream-response-to-file/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Running this demo

1. Make sure you run `npm run bootstrap` in the root folder to setup the dependencies
1. Create the `output` directory if it does not already exist (i.e. `mkdir output`)
1. Run `npm start`

Features from https://services.arcgis.com/uUvqNMGPm7axC2dD/arcgis/rest/services/Boating_Access_Sites/FeatureServer/0 will be written in GeoJSON format to a file in the `output` directory.
5 changes: 3 additions & 2 deletions demos/stream-response-to-file/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { request } = require("../../packages/arcgis-rest-request");
const { queryFeatures } = require("@esri/arcgis-rest-feature-service");
const fs = require("fs");
const fetch = require('node-fetch');
require('isomorphic-form-data')
Expand All @@ -15,7 +15,8 @@ const params = {
f: "geojson"
};

request(serviceUrl, {
queryFeatures({
url: serviceUrl,
params,
rawResponse: true,
fetch: fetch
Expand Down
16 changes: 7 additions & 9 deletions demos/stream-response-to-file/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions demos/stream-response-to-file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "stream response to file with arcgis-rest-request",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand All @@ -23,6 +24,10 @@
},
"homepage": "https://github.com/Esri/arcgis-rest-js#readme",
"dependencies": {
"@esri/arcgis-rest-auth": "^1.16.1",
"@esri/arcgis-rest-common-types": "^1.16.1",
"@esri/arcgis-rest-feature-service": "^1.16.1",
"@esri/arcgis-rest-request": "^1.16.1",
"isomorphic-form-data": "^2.0.0",
"node-fetch": "^2.3.0"
}
Expand Down
Loading

0 comments on commit 6fb7c79

Please sign in to comment.