I am attempting to access data from a Google Spreadsheet, however, I am having difficulty getting the code to work.
I was able to add data to the spreadsheet by using API Spreadsheets and the following code:
function SubForm (){
$.ajax({
url:'<API>',
type:'post',
data:$("#myForm").serializeArray(),
success: function(){
alert("Form Data Submitted. Please log in.")
},
error: function(){
alert("There was an error")
}
});
}
However, I can't seem to access the data using similar code. The website I am using for the API provides the following sample code for reading data, however, I am not sure what to make of it and how to implement it.
fetch("<API>").then(res=>{
if (res.status === 200){
// SUCCESS
res.json().then(data=>{
const yourData = data
}).catch(err => console.log(err))
}
else{
// ERROR
}
})
Any help would be appreciated. Thanks!