pagekit / vue-resource

The HTTP client for Vue.js
MIT License
10.08k stars 1.6k forks source link

JSONP request catches error despite callback firing #679

Closed beningreenjam closed 6 years ago

beningreenjam commented 6 years ago

Reproduction Link

https://jsfiddle.net/LqntgLaz/10/

Steps to reproduce

Request to Flickr public API via JSONP on created lifecycle event, using the required function expression attached to the window object with the name of jsonFlickrFeed.

Tested on: Firefox 57.0.4 64-bit (MacOS High Sierra 10.13.3) Version 64.0.3282.186 (Official Build) (64-bit) (MacOS High Sierra 10.13.3) Version 11.0.3 (13604.5.6) (MacOS High Sierra 10.13.3)

What is Expected?

Callback fires without errors and success method within promise fires also

What is actually happening?

Callback fires ok. Promise catches error with an empty Response object (example below).

{
  "url": "https://api.flickr.com/services/feeds/photos_public.gne?tagMode=all&format=json&callback=jsonFlickrFeed&jsonFlickrFeed=_jsonp585991qv8b",
  "ok": false,
  "status": 0,
  "statusText": "",
  "headers": {
    "map": {}
  },
  "body": null
}
steffans commented 6 years ago

Use the jsonpCallback option to set the callback name, see https://jsfiddle.net/LqntgLaz/16/