Promise. Both result and error fired.

hello's Avatar

hello

28 Jul, 2015 12:51 PM

Hi there,

I am using Promise for connecting to Backened.
Is it possible that both result and error are fired?
In my case this is exactly what happening.
First result handler is called, then error handler.

var p:Promise = restClient_drm.post("SOME_URL", obj);
p.addResultHandler(resultHandler);
p.addErrorHandler(errorHandler);
  1. Support Staff 1 Posted by Ondina D.F. on 29 Jul, 2015 09:30 AM

    Ondina D.F.'s Avatar

    Hello hello ;)

    I'm afraid I can't help you much, because my knowledge about promises is more theoretical than practical.

    The 3 lines of code you posted look just fine. The cause of the behaviour you've mentioned must lie somewhere else in your code.
    Try to reduce the complexity of your code. Start with a very basic example. Questions to ask yourself:
    Are you making multiple calls to the server? Are you using some callback functions?
    Are you nesting the remote calls? Are you using more than one promise?
    Are you sure the error handler is called for the same promise?
    The error you're receiving should give you some hints about the origin of the problem, like what happens on your backend server...
    What happens if you don't use promises, does the server respond as expected?

    Ondina

  2. Ondina D.F. closed this discussion on 28 Oct, 2015 03:49 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac