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

tangy-checkboxes-dynamic not fetching forms.json #272

Open
chrisekelley opened this issue Jul 30, 2021 · 1 comment
Open

tangy-checkboxes-dynamic not fetching forms.json #272

chrisekelley opened this issue Jul 30, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@chrisekelley
Copy link
Member

chrisekelley commented Jul 30, 2021

In certain circumstances on an APK, the following code fails even if it has received the payload:

const request = new XMLHttpRequest();
    request.onreadystatechange = function () {
      if (this.readyState === 4 && this.status === 200) {

Even if readyState === 4, the status stays at 0, never reaching 200, but responseText is populated.

@chrisekelley
Copy link
Member Author

chrisekelley commented Jul 30, 2021

Check the fetchLocal function in the code here: Tangerine-Community/Tangerine@aca5b64#diff-654a2a2a2f2db514da7640fbeabb70f9527941294e1c14a28628cd188e440454

function fetchLocal(url) {
      return new Promise(function(resolve, reject) {
        var xhr = new XMLHttpRequest
        xhr.responseType = 'json';
        xhr.onload = function() {
          if (xhr.status < 200 || xhr.status >= 300) {
          	if (xhr.status === 0) {
          		if (Array.isArray(xhr.response)) {
          			resolve(xhr.response)
          		} else {
          			reject({request: xhr});
          		}
          	} else {
          	  reject({request: xhr});
          	}
          } else {
          resolve(xhr.response)
          }
        }
        xhr.open('GET', url)
        xhr.send(null)
      })
    }

@chrisekelley chrisekelley self-assigned this Jul 30, 2021
@chrisekelley chrisekelley added the bug Something isn't working label Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant