Saving data to Pavlovia server

My experiment is not written in PsychoPy due to problems I had with the builder and my specific needs, but I don’t know where else to ask. Sorry if this is irrelevant, but I hope somebody can help me.

My code collects participant demographics and stores it in a Javascript object, which can be converted to JSON.
My code also collects data for each trial as an object, which is put in an array that is appended each trial. This can also be converted to JSON

My question is, how do I save this information to the data folder of my Gitlab at the end of the experiment?
Is there simple code I can implement for this?
Or do I need to implement PsychoJS into my code? If so, is that possible without converting my whole project to PsychoJS?

Any help would be greatly appreciated. If more information is needed, please let me know.
Thanks!

Example JSON of participant info:
“{“initials”:“EMR”,“age”:“24”,“gender”:“F”,“percent mammo”:“25”,“years experience”:“12”,“cases per year”:“1400”,“screen size”:68.58,“image_pixels”:562}”

Example JSON of participant data:
“[{“block”:“F0/”,“trialnum”:1,“imagenum”:“N63”,“rating”:77,“rt”:2015},{“block”:“F0/”,“trialnum”:2,“imagenum”:“AC1”,“rating”:15,“rt”:1007},{“block”:“F0/”,“trialnum”:3,“imagenum”:“AP3”,“rating”:91,“rt”:899},{“block”:“F1/”,“trialnum”:1,“imagenum”:“N1”,“rating”:26,“rt”:702},{“block”:“F1/”,“trialnum”:2,“imagenum”:“N2”,“rating”:84,“rt”:570},{“block”:“F1/”,“trialnum”:3,“imagenum”:“AC1”,“rating”:66,“rt”:1001},{“block”:“F1/”,“trialnum”:4,“imagenum”:“AP1”,“rating”:10,“rt”:1267},{“block”:“F1/”,“trialnum”:5,“imagenum”:“AC2”,“rating”:95,“rt”:731},{“block”:“F1/”,“trialnum”:6,“imagenum”:“AP2”,“rating”:2,“rt”:1131},{“block”:“F1/”,“trialnum”:7,“imagenum”:“AD1”,“rating”:99,“rt”:1009},{“block”:“F1/”,“trialnum”:8,“imagenum”:“AD2”,“rating”:12,“rt”:738},{“block”:“F2/”,“trialnum”:1,“imagenum”:“AC1”,“rating”:86,“rt”:958},{“block”:“F2/”,“trialnum”:2,“imagenum”:“AP1”,“rating”:79,“rt”:850},{“block”:“F2/”,“trialnum”:3,“imagenum”:“N2”,“rating”:61,“rt”:658},{“block”:“F2/”,“trialnum”:4,“imagenum”:“AD2”,“rating”:85,“rt”:625},{“block”:“F2/”,“trialnum”:5,“imagenum”:“AP2”,“rating”:68,“rt”:1026},{“block”:“F2/”,“trialnum”:6,“imagenum”:“AC2”,“rating”:90,“rt”:881},{“block”:“F2/”,“trialnum”:7,“imagenum”:“N1”,“rating”:86,“rt”:970},{“block”:“F2/”,“trialnum”:8,“imagenum”:“AD1”,“rating”:10,“rt”:1554}]”

1 Like

I have a very similar issue, having developed a Javascript (using p5.js), I need to save the data it generates into the Pavlovia data folder, but cannot discover how to do this. Any guidance or example code would be much appreciated.

Did you figure this out? I need help with this too!

1 Like

any luck?

1 Like

I have not found a solution, so I had to abandon Pavlovia and host my experiment elsewhere, sorry…

where did you end up hosting it?

I hosted a database (sql) and database manager (written in python) on an EC2 instance of AWS and used POST and GET requests to the server URL put data there and request block orders respectively.

Code snippet of the POST to give you an idea:
this.completeExperiment = {
“uuid”: this.uuid,
“result”: this.data
};
fetch(this.serverUrl + ‘/session/complete’, {
method: ‘POST’,
body: JSON.stringify(completeExperiment),
})
.then((response) => response.json())
.then((result) => {
console.log(‘Success:’, result);
// show end text and anything you want to happen on success

        })

        .catch((error) => {
            console.error('Error:', error);

//put here how to deal with error from the post request

        });