Commit 75923eee authored by Magnus Holm Brunbjerg's avatar Magnus Holm Brunbjerg
Browse files

No nameless experiments

parent e0d75dd7
......@@ -114,8 +114,7 @@ app.route('/experiments')
const experimentContent = {
user_id: req.body.userId,
name: req.body.name,
start_time: new Date(),
end_time: new Date()
time: new Date()
}
// Create new experiment
fetch(`${api}/experiments`, {
......@@ -127,14 +126,18 @@ app.route('/experiments')
if (response.status === 200) { return response.json() }
}).then((experiment) => {
if (experiment) {
fetch(`${api}/experiments/${experiment.id}`, {
method: 'POST',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(experimentContent)
}).then(() => {
if (req.body.name) {
fetch(`${api}/experiments/${experiment.id}`, {
method: 'POST',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(experimentContent)
}).then(() => {
res.redirect('/')
})
} else {
res.redirect('/')
})
}
} else {
res.redirect('/')
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment