[Vuejs]-How to assign function to question in POST?

0👍

You need to return a value from renderAnswers.

methods: {
    // add a return statement
    renderAnswers() {
        return this.question.map((isAnswer) => ({ answers: isAnswer }))
    },
    async createQuiz(quiz, question) {
      try {
        let add = await axios.post("http://localhost:3000/v1/quiz/" , {
            name: quiz.name,
            type: question.type,
            question: this.renderAnswers(),
        });
        router.push({path: '/listQuizzesInstructor'});
      } catch(e) {
          this.errors.push(e);
      }
}

Leave a comment