Hi,
I am now doing an online experiment via URL and trying to collect data using dropbox javascript SDK.
At the end of the experiment, the success message was always prompted. But the data was not always uploaded to my dropbox.
About 1/5 data was missing on the way to my dropbox.
I have no idea why the data is missing and need help with possible reasons.
Here is my code. Each file is about 30kb, so the file size shouldn't be a problem.
I don't know if this is the right way to place the question. Is any extra information needed?
require("dotenv").config();
var Dropbox = require("dropbox").Dropbox;
const fetch = require("node-fetch");
const dbx = new Dropbox({
accessToken: #############,
refreshToken: #############,
clientId: #############,
clientSecret: #############,
fetch
});
var saveDropbox = function(content, filename){
dbx.filesUpload({
path: "/" + filename,
contents: content
})
};
app.post("/experiment-data/:filename", function(request, response){
// convert json to csv
DATA_CSV = json2csv(request.body);
var filename = request.params.filename;
savedropbox(DATA_CSV, filename);
response.end();
});
function(){
var sel_data = jsPsych.data.get();
$.ajax({
type: "POST",
url: "/experiment-data/" + filename,
data: JSON.stringify(sel_data.values()),
contentType: "application/json"
}).done(function(){
alert("You have compeleted the experiment and your data has been
saved! ");
}).fail(function(){
alert("A problem occurs while writing data to Dropbox. "
+ "Data will be saved to your computer. ";
var csv = sel_data.csv();
downloadCSV(csv, fname);
});