I have a requirement to allow users to export data into a csv file from a few different document libraries. The data will be a select number of columns and filtered based on if the document is new or was modified that day. The user needs to be able to compose a csv file from each library individually, or all of the libraries.
What is the best way to fulfill this requirement utilizing javascript/jQuery? I am not able to run a Powershell script and unfortunately I do not have Visual Studio.
EDIT, based on the below answer, I was able to successfully make the rest call to get the data, but I am experiencing an "Uncaught TypeError: Cannot read property 'results' of undefined". I can't figure out why the results are undefined? See code below:
$(document).ready(function getAllLibraries(){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists",
method: "GET",
heders: {"Accept": "application/json; odata=verbose"},
success: function(data){
alert("Success");
var csv = "data:text/csv;charset=utf-8,";
var keys;
if (data.d.results.length > 0 ){
keys = Object.keys(data.value[0]);
csv += keys.join(",") + "\n";
}
for (var j = 0; j < data.d.results.length; j++){
for (var k = 0; k < keys.length; k++){
csv += data.value[j][keys[k]];
csv += k < keys.length -1 ? "," : "";
}
csv += "\n";
}
},
error: function(data){
alert("Error"+ data);
}
});
var a = document.createElement("a");
a.setAttribute("href", encodeURI(csv));
a.setAttribute("download", "data.csv");
$("#ViewLists").appendChild(a);
a.click();
});