
import axios from 'axios'
import moment from 'moment';
// baseUrl 	http://133.186.211.179/api/v3
axios.defaults.baseURL = 'http://133.186.211.179/api/v3';
axios.defaults.headers.common['x-aliot-token'] = '643f43d975132f6d69f3ad14851c92d8d49450c96a38cb32e338dc2d2cedb7e146222f709ead0d93d32b8ec7adb7dd85d99451bd20fda3097db2c993fc9478ca' ;
axios.defaults.headers.post['Content-Type'] = 'application/json';

let meToken = "";
axios.interceptors.request.use(config =>{
    if(config.url == "/auth" || config.url == "/me"){config.headers.interfaceId = 'auth';}
    if(config.url == "/me"){ config.url += `/${meToken}`;}
    if(config.url == "/meditation"){config.headers.interfaceId = 'meditation';}
    // if(config.url == "/bbs"){config.headers.interfaceId = 'bbs';}
    
    config.headers.timestamp = moment().format('YYYYMMDDHHmmssSSS');
    return config;  
})  
// axios({
//     baseURL : "http://133.186.211.179",
//     headers: {'x-aliot-token' :'643f43d975132f6d69f3ad14851c92d8d49450c96a38cb32e338dc2d2cedb7e146222f709ead0d93d32b8ec7adb7dd85d99451bd20fda3097db2c993fc9478ca' ,
                        
//                         },
//   });
class Net { 
    constructor (){ 
        // console.log('==================' , axios); 
    }
    async login (obj){  
        let {data} =    await axios.post("/auth" , obj);  
        if(data && data.result && data.result.token){
            meToken = data.result.token;
        }
        // console.log(data);   
        
    }
    async me(obj){
        let {data} =    await axios.get(`/me/${meToken}` );
        return data;      
    }   
    async updateMe(obj){
        let {data} =    await axios.post(`/me/${meToken}`, obj );
        return data;
    }   


    async meditation (obj){
        let {data} =    await axios.post("/meditation",obj);  
        return data;
        // console.log(" :::: " , data);       
    }
    async notice(){
       // 공지 사항
        let {data} =    await axios.get("/bbs/notice");  
        // console.log(data);
        return data;
    }

    async faq(){
        // FAQ 
        let {data} =    await axios.get("/bbs/faq");  
        return data;
    }
 
}

export default (new Net())




