Skip to content

Commit 02366c9

Browse files
authored
Fix #775 (#776)
* Fix #775 Prevent modules from compiling in react-native * clean up
1 parent 3b14bd5 commit 02366c9

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/ParseFile.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -316,26 +316,26 @@ const DefaultController = {
316316
download: function(uri) {
317317
if (XHR) {
318318
return this.downloadAjax(uri);
319-
}
320-
if (process.env.PARSE_BUILD === 'browser') {
319+
} else if (process.env.PARSE_BUILD === 'node') {
320+
return new Promise((resolve, reject) => {
321+
const client = uri.indexOf('https') === 0
322+
? require('https')
323+
: require('http');
324+
client.get(uri, (resp) => {
325+
resp.setEncoding('base64');
326+
let base64 = '';
327+
resp.on('data', (data) => base64 += data);
328+
resp.on('end', () => {
329+
resolve({
330+
base64,
331+
contentType: resp.headers['content-type'],
332+
});
333+
});
334+
}).on('error', reject);
335+
});
336+
} else {
321337
return Promise.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
322338
}
323-
return new Promise((resolve, reject) => {
324-
const client = uri.indexOf('https') === 0
325-
? require('https')
326-
: require('http');
327-
client.get(uri, (resp) => {
328-
resp.setEncoding('base64');
329-
let base64 = '';
330-
resp.on('data', (data) => base64 += data);
331-
resp.on('end', () => {
332-
resolve({
333-
base64,
334-
contentType: resp.headers['content-type'],
335-
});
336-
});
337-
}).on('error', reject);
338-
});
339339
},
340340

341341
downloadAjax: function(uri) {

0 commit comments

Comments
 (0)