Move to node fetch API for web requests instead of XHR (#1552)

* Use node-fetch instead of xhr

* Remove XMLHttpRequest.js

// FREEBIE

* Avoid calling json() on non json responses

Previously we would catch and swallow JSON parsing errors resulting from an
empty response, though empty responses are normal from a few endpoints, like
requesting sms or voice registration codes.

Since the JSON parsing call is now handled internally by node-fetch, we have to
keep closer track of our expected response type to avoid throwing an exception.

// FREEBIE
This commit is contained in:
Lilia 2017-10-20 15:52:02 -07:00 committed by Scott Nonnenberg
parent 0d3c70151d
commit af8b0164b5
7 changed files with 177 additions and 770 deletions

View file

@ -101,7 +101,6 @@ module.exports = function(grunt) {
'!js/Mp3LameEncoder.min.js',
'!js/libsignal-protocol-worker.js',
'!js/components.js',
'!js/XMLHttpRequest.js',
'!js/signal_protocol_store.js',
'_locales/**/*'
],
@ -170,7 +169,6 @@ module.exports = function(grunt) {
'!js/Mp3LameEncoder.min.js',
'!js/libsignal-protocol-worker.js',
'!js/components.js',
'!js/XMLHttpRequest.js',
'test/**/*.js',
'!test/blanket_mocha.js',
'!test/test.js',