import m from "mithril"

const User = {
    list: [],
    current: {},
    loading: false,
    fetchList: function() {
        User.list = require("../../json/users/example").data
    },
    fetchCurrent: function(userId) {
        User.loading = true
        m.request({
            url: "http://api.questionnaire.dev/v1/users/" + userId,
            method: "GET"
        })
        .then(function(res) {
            User.current = res
            User.loading = false
        })
    },
    regist: function() {

    },
    login: function() {
        m.route.set("/user/questionnaires")
    },
    logout: function() {

    }
}

export default User
