mw.api.postWithToken now forwards promise on fail if we have token
authorNiklas Laxström <niklas.laxstrom@gmail.com>
Tue, 22 Oct 2013 09:50:05 +0000 (09:50 +0000)
committerNiklas Laxström <niklas.laxstrom@gmail.com>
Tue, 22 Oct 2013 09:50:05 +0000 (09:50 +0000)
Without this fix the callers of this function could not read the
failure code and result, because we returned undefined. Because
we are using a filter function, we need to explicitly return the
promise to pass it forward.

Change-Id: I71984ac827618459f723b0b9f47d4dc29e2a2f70

resources/mediawiki.api/mediawiki.api.js

index f9a14b0..cdc6767 100644 (file)
                                                        tokenCache[tokenType] = params.token = undefined;
                                                        return api.post( params );
                                                }
+                                               // Pass the promise forward, so the caller gets error codes
+                                               return this;
                                        }
                                );
                        } else {