question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expose new responseType option in IRequestOptions

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jgravoiscommented, Feb 14, 2019

closed via #457. thx @tannerjt! 🚀

0reactions
thw0rtedcommented, Mar 29, 2021

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting http option as 'responseType: 'text'' causes compile ...
Assigning it as a string like this won't work straight away. You can either cast it as a text type const opts =...
Read more >
Update typings for functions that wrap `request()` to return ...
The main motivation for rawResponse comes from expose new responseType option in IRequestOptions #373 when our recommended fetch ...
Read more >
XMLHttpRequest.responseType - Web APIs | MDN
The XMLHttpRequest property responseType is an enumerated string value specifying the type of data contained in the response.
Read more >
scarlett - npm
A strongly typed, Typescript powered, rest client library based on Fetch API.. Latest version: 1.4.1, last published: 6 months ago.
Read more >
HttpRequest - Angular
HttpParams; responseType?: ... method, headers, body, and other request configuration options. ... new HttpParams({fromString: 'angular=awesome'}).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found