Skip to content

Instantly share code, notes, and snippets.

@johnflux
Created August 17, 2016 04:35
Show Gist options
  • Save johnflux/c22667573a66d642361a8778822bb454 to your computer and use it in GitHub Desktop.
Save johnflux/c22667573a66d642361a8778822bb454 to your computer and use it in GitHub Desktop.
class FetchRest {
....
putValue(name, value) {
// Set value via REST as well as updating the state
var newParameters = {...this.component.state.api, [parameterName] : value};
this.component.setState({api: newParameters});
fetch( this.restServerUrl + '/api/' + name,
{
method: 'PUT',
headers: this.header,
body: JSON.stringify(value)
});
}
handleReset() {
this.context.apiCallbacks.putValue("gamma", {r:1,g:1,b:1});
this.context.apiCallbacks.putValue("blackLevel", {r:0.3,g:0.3,b:0.3});
this.context.apiCallbacks.putValue("whiteLevel", {r:1,g:1,b:1});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment