expose new responseType option in IRequestOptions
See original GitHub issueI’m working with Node 8.6.0 in a linux environment. I was trying to request an image export from an image server when I ran into an error: “error: TypeError: response.blob is not a function.” When the format is set to image rather than resolve with the image buffer, the request throws an error.
I’ve traced the error down to the format setting. When the parameters are set and format is image the promise should resolve and the image buffer should be returned, but it does not, and throws an error in request.ts. Based on the structure of that file, and the switch statement on params.f I’m guessing that the ‘zip’ format will also fail.
Investigating a bit further I found #bitinn/node-fetch/issues/78 which references response.blob being browser only.
I put together a quick test:
require("isomorphic-fetch");
require("isomorphic-form-data");
const { request } = require("@esri/arcgis-rest-request");
const imageServiceURL = 'https://geodata.md.gov/imap/rest/services/Imagery/MD_SixInchImagery/ImageServer';
// if f='json' this will work in Node
// when f='image' request fails with 'response.blob is not a function' error
const params = {
bbox: '-8529110,4764085,-8528610,4764085',
bboxSR: '102100',
size: '400,400',
imageSR: '102100',
format: 'png8',
pixelType: 'U8',
noDataInterpretation: 'esriNoDataMatchAny',
interpolation: '+RSP_BilinearInterpolation',
f: 'image'
};
request(imageServiceURL + '/exportimage', { httpMethod: 'POST', params })
.then( result => {
console.log({result});
})
.catch( error => { console.log({error})});
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
closed via #457. thx @tannerjt! 🚀
Anybody following this might be have insight on my question in #462 , i.e. do we need a new issue to have all the methods that think they return a JSON collection, but can now also return a
Response
, updated to account for this?