33 lines
883 B
JavaScript
Vendored
33 lines
883 B
JavaScript
Vendored
import m from "mithril"
|
|
|
|
const QuestionAnswer = {
|
|
list: [],
|
|
current: {},
|
|
loading: false,
|
|
fetch: function(questionId) {
|
|
QuestionAnswer.loading = true
|
|
m.request({
|
|
url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers",
|
|
method: "GET"
|
|
})
|
|
.then(function(res) {
|
|
QuestionAnswer.loading = false
|
|
console.log("response: ", res);
|
|
})
|
|
},
|
|
upload: function(questionId) {
|
|
QuestionAnswer.loading = true
|
|
m.request({
|
|
url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers",
|
|
method: "POST",
|
|
data: QuestionAnswer.current
|
|
})
|
|
.then(function(res) {
|
|
QuestionAnswer.loading = false
|
|
console.log("response: ", res);
|
|
})
|
|
}
|
|
}
|
|
|
|
export default QuestionAnswer
|