I am trying to save data to MongoDB, But this error is occurring.
I am trying to export the describe function to save data on MongoDB onclick on Complete button. Also, why is it var app is not showing on my page when I include const demo = require on my index.js. I think I need it to import the describe function. I don't know what's wrong, please send help.
This is my index.js
const demo = require("./demo_test")
Survey
.StylesManager
.applyTheme("defaultV2");
const json = {
pages: [
{
questions: [
{
type: "radiogroup",
name: "Question 1",
title: "Deliver through others.",
choices: [
"Not effective",
"Neither effective nor Effective",
"Effective"
]
},
{
type: "radiogroup",
name: "Question 2",
title: "Understand others perspective.",
choices: [
"Not effective",
"Neither effective nor Effective",
"Effective"
]
},
{
type: "radiogroup",
name: "Question 3",
title: "Solve complex problems.",
choices: [
"Not effective",
"Neither effective nor Effective",
"Effective"
]
},
]
}
]
};
window.survey = new Survey.Model(json);
survey
.onComplete
.add(function (sender) {
let data = JSON.stringify(sender.data)
data = data.replaceAll("Not effective", "A")
data = data.replaceAll("Neither effective nor Effective", "B")
data = data.replaceAll("Effective", "C")
var obj = JSON.parse(data)
document
.querySelector('#surveyResult')
.textContent = "Result JSON:\n" + JSON.stringify(obj, null, 3);
describe(obj)
});
var app = new Vue({
el: '#surveyElement',
data: {
survey: survey
}
});
this is my demo_test.js
const mocha = require('mocha')
const { assert } = require('assert');
const Question = require('../models/questions');
describe('Saving records', function(obj){
it('Saves a record to the database', function(done){
var char = new Question({
obj
});
char.save().then(function(){
assert(char.isNew === false);
done();
});
});
});
module.exports = describe();