Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-sdk xhrAddEventListener is not function #1418

Closed
snz2 opened this issue Jan 7, 2017 · 1 comment
Closed

aws-sdk xhrAddEventListener is not function #1418

snz2 opened this issue Jan 7, 2017 · 1 comment

Comments

@snz2
Copy link

snz2 commented Jan 7, 2017

web platform is ok. but android, ios, simulator is this message.

I guess it's DOM element object.

another solution? or aws-sdk all platform support ?

thanks

@snz2
Copy link
Author

snz2 commented Jan 7, 2017

answer myself:

Edit: aws-sdk/lib/http/xhr.js

addeventlistener To

xhr.onreadystatechange = function(){
      try {
        if (xhr.status === 0) return; // 0 code is invalid
      } catch (e) { return; }

      if (!headersEmitted) {
        try { xhr.responseType = 'arraybuffer'; } catch (e) {}
        emitter.statusCode = xhr.status;
        emitter.headers = self.parseHeaders(xhr.getAllResponseHeaders());
        emitter.emit('headers', emitter.statusCode, emitter.headers);
        headersEmitted = true;
      }

      if (this.readyState === this.DONE) {
        self.finishRequest(xhr, emitter);
      }
    };

//native not defined 
    // xhr.upload.onprogress = function(evt){
    //   emitter.emit('sendProgress', evt);
    // };

    xhr.onprogress= function(evt){
      emitter.emit('receiveProgress', evt);
    };

    xhr.ontimeout = function(){
      errCallback(AWS.util.error(new Error('Timeout'), {code: 'TimeoutError'}));
    };

    xhr.onerror=function(){
      errCallback(AWS.util.error(new Error('Network Failure'), {
        code: 'NetworkingError'
      }));
    };

@nantas nantas closed this as completed Feb 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants