Skip to content

Instantly share code, notes, and snippets.

@simistern
Last active February 26, 2019 17:19
Show Gist options
  • Save simistern/44f3b999c12cce5375a02b0234066cdc to your computer and use it in GitHub Desktop.
Save simistern/44f3b999c12cce5375a02b0234066cdc to your computer and use it in GitHub Desktop.
var requests = {
set: createPostRequest('POST', 'text'),
get: createRequest('GET', 'query')
};
function createPostRequest(type, method, payload) {
twitch.rig.log($("#input").val()); //input
return {
type: type,
url: location.protocol + '//localhost:8081/sayit/' + method,
success: updateBlock,
contentType: "application/x-www-form-urlencoded",
data: {body: payload},
error: logError
}
}
function createRequest(type, method) {
return {
type: type,
url: location.protocol + '//localhost:8081/sayit/' + method,
success: updateBlock,
error: logError
}
}
$.ajax(requests.set);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment