Skip to content

Instantly share code, notes, and snippets.

@jazzyjackson
Last active March 12, 2020 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jazzyjackson/562f6f5ef0abca39833bdf3c29f07b4d to your computer and use it in GitHub Desktop.
Save jazzyjackson/562f6f5ef0abca39833bdf3c29f07b4d to your computer and use it in GitHub Desktop.
<!-- an example of using the kvetch function -->
<!-- https://github.com/jazzyjackson/kvetch.js -->
<script src="wherever you cloned this file/kvetch.js">
<script>
kvetch.get('/', {anything: 'you want'})
// becomes '/?anything=you%20want'
kvetch.post('/somedata', null, {
"key-1" : "some data you want to send as a JSON body",
"key-b" : "the headers and cookies and everything else are handled for you"
}).then(res => res.json()).then(data => /* any call to kvetch returns the fetch it invoked */)
var someSignUpSheet = new FormData()
someSignUpSheet.append('firstName','your')
someSignUpSheet.append('middleName','latest')
someSignUpSheet.append('lastName', 'identity')
kvetch.put('/signUp', {metadata: 'extra info'}, someSignUpSheet)
.then(()=> alert("success!"))
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment