Make second successful request to REST API return a good promise

Why:
* The IPInfo REST APIs introduced the requirement for a CSRF token
  to prevent CSRF attacks.
* If the token was invalid on the first request, the code is
  configured to re-attempt the request after getting a new CSRF
  token. However, if this second request is a success the code
  will not return a promise that is marked as a success.

What:
* Use a $.Deferred() as the promise to return instead of the
  promise from api.getToken() in postToRestApi() of rest.js.
* Add success and fail handlers which will reject or resolve the
  $.Deferred() promise returned by postToRestApi.

Bug: T356183
Change-Id: I32d1aae3a7f2654acbd978486de3c4eb8293dd58
1 file changed