Last active
October 29, 2019 09:22
-
-
Save topherPedersen/4e2872ff8b89cc3ee0fb606a1c377e7f to your computer and use it in GitHub Desktop.
That Equals This?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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