Skip to content

Instantly share code, notes, and snippets.

@scroobius-pip
Created September 8, 2020 09:51
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 scroobius-pip/7dc4a88e5e39b5343d76f0bdc7b250cb to your computer and use it in GitHub Desktop.
Save scroobius-pip/7dc4a88e5e39b5343d76f0bdc7b250cb to your computer and use it in GitHub Desktop.
<html>
<body>
<form action="javascript:submit()">
<label for="name">What's your name ?</label><br>
<input required type="text" id="name" name="name" value=""><br>
<label for="email">What's your email ?</label><br>
<input required type="email" id="email" name="email" value=""><br>
<input type="submit" id="submit" value="Submit">
</form>
</body>
<script>
function submit (){
var sheetName = "Sheet1" //enter the sheet name
var sheetId = "1ciV-RLMAZ_bOMTva4ThsJ9XT2YnbswnvBAUBzvcoURs" //enter the sheet id
var apiKey = "w8pv4JvNbZSjlhcN0JvKRz3zXtPIoyOPddIICD5nwWunPlKc6Kf7C3QSHEo"
document.getElementById("submit").value = "Loading..."
var email = document.getElementById("email").value
var name = document.getElementById("name").value
fetch("https://api.sheetson.com/v2/sheets/"+sheetName,{
method:"POST",
headers:{
"Authorization": "Bearer "+apiKey,
"X-Spreadsheet-Id": sheetId,
"Content-Type":"application/json"
},
body: JSON.stringify({name,email})
}).then(result=>{
console.log(result)
document.getElementById("submit").value = "Thank You!"
})
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment