const requestFunc = async(url, method = "GET", data = null, token = null) => {
	apihost = 'http://schedule.tomtit.tomsk.ru/api'
	method = method.toLocaleUpperCase()
	let fullurl = `${apihost}${url}`;
	let options = {
	method: method,
	headers: {
	"Content-Type": "application/json",
	"Authorization": `Bearer ${token}`,
	},
};

switch(method) {
	case "PUT":
	delete options.headers["Content-Type"];
	options.body = data;
	break;
	case "POST": case "PATCH": case "DELETE":
	options.body = JSON.stringify(data);
	break;
}

const res = await fetch(fullurl, options);
return await res.json();
};
<<<<<<< HEAD
<<<<<<< HEAD
var app = new Vue({
=======

var vueapp = new Vue({
>>>>>>> master
=======
var app = new Vue({
>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
        el: '#app',
        delimiters: ['${', '}'],
        data: {
            groups:[],
            teachers:[],
<<<<<<< HEAD
<<<<<<< HEAD
            selected:null
         },
=======
            specialties:[],
        },
>>>>>>> master
=======
            selected:null
         },
>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
        methods: {
            showGroups() {
                console.log(this.groups)
            },
        	async getGroups(){
        		this.groups = await requestFunc("/group/", "GET")
        	},
            async getTeachers(){
                teachers = await requestFunc("/teacher/", "GET")
                for(let i =0; i < teachers.length; i++) {
                    Vue.set(this.teachers, i, teachers[i]);
                }
            },
<<<<<<< HEAD
<<<<<<< HEAD
            async mountFunc(){
                await this.getTeachers()
                await this.getGroups()
            },
=======
            async getSpecilties(){
                specialties = await requestFunc("/specialty/", "GET")
                for(let i =0; i < specialties.length; i++) {
                    Vue.set(this.specialties, i, specialties[i]);
                }
            },
            async mountFunc(){
                await this.getTeachers()
                await this.getGroups()
                await this.getSpecilties()
            }
>>>>>>> master
=======
            async mountFunc(){
                await this.getTeachers()
                await this.getGroups()
            },
>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
        }, 
        async mounted() {
            await this.mountFunc()
            console.log(this.teachers)
        }
    });




<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
// const requestFunc = async(url, method = "GET", data = null, token = null) => {
//     apihost = 'http://schedule.tomtit.tomsk.ru/api'
//     method = method.toLocaleUpperCase()
//     let fullurl = `${apihost}${url}`;
//     let options = {
//     method: method,
//     headers: {
//     "Content-Type": "application/json",
//     "Authorization": `Bearer ${token}`,
//     },
// };
<<<<<<< HEAD

// switch(method) {
//     case "PUT":
//     delete options.headers["Content-Type"];
//     options.body = data;
//     break;
//     case "POST": case "PATCH": case "DELETE":
//     options.body = JSON.stringify(data);
//     break;
// }

// const res = await fetch(fullurl, options);
// return await res.json();
// };
// var app = new Vue({
//         el: '#app',
//         delimiters: ['${', '}'],
//         data: {
//             groups:[],
//             teachers:[],
//             profmoduls:[],
//          },
//         methods: {
//             showGroups() {
//                 console.log(this.groups)
//             },
//             async getGroups(){
//                 this.groups = await requestFunc("/group/", "GET")
//             },
//             async getTeachers(){
//                 teachers = await requestFunc("/teacher/", "GET")
//                 for(let i =0; i < teachers.length; i++) {
//                         Vue.set(this.teachers, i, teachers[i]);
//                     },
//             },
//             async mountFunc(){
//                 await this.getTeachers()
//                 await this.getGroups()
//             },
//         }, 
//         async mounted() {
//             await this.mountFunc()
//             console.log(this.teachers)
//         }
//     });
=======
=======
>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12

// switch(method) {
//     case "PUT":
//     delete options.headers["Content-Type"];
//     options.body = data;
//     break;
//     case "POST": case "PATCH": case "DELETE":
//     options.body = JSON.stringify(data);
//     break;
// }

<<<<<<< HEAD
>>>>>>> master
=======
// const res = await fetch(fullurl, options);
// return await res.json();
// };
// var app = new Vue({
//         el: '#app',
//         delimiters: ['${', '}'],
//         data: {
//             groups:[],
//             teachers:[],
//             profmoduls:[],
//          },
//         methods: {
//             showGroups() {
//                 console.log(this.groups)
//             },
//             async getGroups(){
//                 this.groups = await requestFunc("/group/", "GET")
//             },
//             async getTeachers(){
//                 teachers = await requestFunc("/teacher/", "GET")
//                 for(let i =0; i < teachers.length; i++) {
//                         Vue.set(this.teachers, i, teachers[i]);
//                     },
//             },
//             async mountFunc(){
//                 await this.getTeachers()
//                 await this.getGroups()
//             },
//         }, 
//         async mounted() {
//             await this.mountFunc()
//             console.log(this.teachers)
//         }
//     });
>>>>>>> b5fe990a18b258e28401117b0be0a70e1a10db12
