Object doesn't support property or method '

2019-07-10 00:51发布

问题:

  • servicestack-client version 1.0.9
  • Microsoft Edge 38.14393.2068.0
  • Microsoft EdgeHTML 14.14393

I am getting the following Javascript error in Microsoft Edge 38.14393.2068.0:

"Object doesn't support property or method 'json'"

I suspecting that this Microsoft Edge Javascript error is coming from the ServiceStack Typescript JsonServiceClient, you can find this npm package's source code is here

Use the standalone app below to reproduce this issue in MS Edge:

  • clone this repository, just follow these commands:
  • git clone https://github.com/Sweetog/servicestack-angular.git
  • npm install
  • npm run serve
  • Watch console in Chrome and MS Edge http://localhost:8080/#/sandbox

You will see Chrome works fine but MS Edge fails with the "Object doesn't support property or method 'json'" error.

If there is a valid bearerToken, both MS EDGE and Chrome requests work.

回答1:

I can't reproduce this exact error but I've found an issue with MS Edge where it throws a DOMException when calling W3C fetch's .json() API on an empty JSON response which is resolved in this commit. This fix is available from v0.0.41 of servicestack-client that's now available on npm.

If this doesn't solve your issue, please create a small stand-alone example which we can run that repro's the issue.