mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
[react-packager][streamline oss] Move open sourced JS source to react-native-github
This commit is contained in:
22
packager/react-packager/example_project/js/XHR.js
vendored
Normal file
22
packager/react-packager/example_project/js/XHR.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @providesModule XHR
|
||||
*/
|
||||
|
||||
function request(method, url, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open(method, url);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
callback(null, xhr);
|
||||
} else {
|
||||
callback(new Error('status = ' + xhr.status, xhr));
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
exports.get = function(url, callback) {
|
||||
request('GET', url, callback);
|
||||
};
|
||||
Reference in New Issue
Block a user