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

Add startWebRequestSync to App Lab (hidden from the toolbox) #26191

Merged
merged 1 commit into from Dec 14, 2018

Conversation

joshlory
Copy link
Contributor

Sample usage:

button("btn", "load");
textLabel("txt", "");

onEvent("btn", "click", function(event) {
  setText("txt", "Loading...");
  
  var result = startWebRequestSync("https://api.openweathermap.org/data/2.5/weather?q=Chicago");
  setText("txt", result);
});

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Prototype!

opts.func(responseText);
}
});
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the web request fails? It seems like it should throw - do we get that for free with nativeIsAsync or do we need to handle it here where we're wrapping the callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior of startWebRequest is that it calls the callback with the error. I matched that behavior for the synchronous version (the error message is returned to the caller).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@joshlory
Copy link
Contributor Author

Request from @gtw!

@joshlory joshlory merged commit ce3c25b into staging Dec 14, 2018
@joshlory joshlory deleted the applab-sync-web-req branch December 14, 2018 19:06
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

Successfully merging this pull request may close these issues.

None yet

3 participants