View Code? Open in Web Editor
NEW
A template for creating and hosting online psychology experiments using JsPsych and GitHub
Home Page: https://templateonlineexperiment.netlify.app
JavaScript 68.03%
HTML 9.51%
Python 1.71%
R 20.75%
templateonlineexperiment's Introduction
Template for JsPsych Experiments
The setup includes:
experiment.js file:
where the experiment is coded
the commitToRepo() function to send the jsonData to netlify function
.netlify/functions/api
where the jsonData is received and pushed to repo
How to Setup the authentication
Create Netlify account and sync with the GitHub repository to be deployed
Go to Deploy Settings > Functions > Settings > Functions directory and add directory where functions will be stored i.e., .netlify/functions/api
Go to GitHub settings (under your own profile) > Developer settings > Personal access tokens and generate a new token.
Go to Environment under the same netlify settings to add a GH_TOKEN
environment variable, which is the value of the personal access token
Customization: Edit the .netlify/functions/api.js file
Commit information
Function: createOrUpdateFileContents()
committer.name
committer.email
author.name
author.email
templateonlineexperiment's People
Stargazers
templateonlineexperiment's Issues
I'd like to add IP / localization information. Here I've found this nice little piece of code:
fetch ( 'https://extreme-ip-lookup.com/json/' )
. then ( res => res . json ( ) )
. then ( response => {
console . log ( "Country: " , response . country ) ;
} )
. catch ( ( data , status ) => {
console . log ( 'Request failed' ) ;
} )
That fetches a json object containing some useful information. However, I'd like to put it in a function so that it returns the whole object, or an object {status: "failure"}
if it fails. But I don't know how to extract the whole response
object from the .then
promise π
@penguimelia any idea?
let's open an issue to track my attempts ^^ thanks a ton @penguimelia for having looked into that π βΊοΈ