Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
That Equals This?
handleRefreshData(paramOne, paramTwo, oldState) {
var that = this;
var httpRequest = new XMLHttpRequest();
var httpRequestURL = "https://mysupersweetdomain.com/my-route";
httpRequest.open("POST", httpRequestURL, true);
httpRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Get Response Data
var data = this.responseText;
data = JSON.parse(data);
// Update State With Fresh Financial Data HERE
var newState = oldState;
newState.foo = data.foo;
newState.bar = data.bar;
newState.baz = data.baz;
that.setState(newState); // update state with fresh financial data
}
};
var formData = new FormData();
formData.append("abc", paramOne);
formData.append("xyz", paramTwo);
httpRequest.send(formData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.