0
votes

I am trying to make a request using iron-ajax.

My code looks like this:

<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">

<iron-ajax
  id="fetch"
  url="myapi.com/resource"
  method="GET"
  content-type="application/json"
  handle-as="json"
  on-response="storeData"
  debounce-duration="300" auto>
</iron-ajax>

I consistently get this error and have linked to the source below.

Uncaught TypeError: request.completes.then is not a function

https://github.com/PolymerElements/iron-ajax/blob/master/iron-ajax.html#L447

When I log the spawned iron-request object request.completes out to my console, I see the below object.

g
_callbacks: Object
_pendingCallbacks: Object
ctx: null
promiser: ()
__proto__ : Object

I am using the following versions, and polymer serve to run the app locally.

iron-ajax: 1.4.3 polymer: 1.7

1
What is the content of your event handler, namely storeData? Also, try to provide a minimal (non)working example.alesc
Thanks, @alesc. the error is the same even if storeData is simply storeData: function(response) { console.log(response) }Mike Spangler
The error seems to indicate that iron-request is unresolved (e.g., it's not defined). Do you have a GitHub link or fiddle that reproduces the problem?tony19
Are you trying to generate request automatically? From my experience, I use generateRequest() method on a given iron-ajax id, to generate the request whenever an event handler is fired (like selected change).Kaung Myat Lwin
@alesc @tony19 this plnkr.co/edit/3GATdWBbiq9P0YlKHn84 shows a minimal, and unfortunately working example. The maddening thing is that it is basically boilerplate code, and request.completes above appears to be a valid promise AFAIK. The setter for request.completes here: github.com/PolymerElements/iron-ajax/blob/master/…Mike Spangler

1 Answers

0
votes

The awful resolution to this is that I had a naming conflict. I use bloodhound.js in this project and recently switched from a manually downloaded file over to bower. The bloodhound registered on bower is NOT the library written by twitter. It is an entirely different, one-starred, zero-forked library, last updated in 2014 that happens to overwrite the Promise prototype at a global scope :(

Thanks to all for your consideration and help!