{"size": 1355, "ext": "js", "max_stars_repo_path": "src/api/client-api.js", "max_stars_repo_name": "ruirui9540/iview_test", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/api/client-api.js", "max_issues_repo_name": "ruirui9540/iview_test", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/api/client-api.js", "max_forks_repo_name": "ruirui9540/iview_test", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.5660377358, "max_line_length": 91, "alphanum_fraction": 0.5564575646}
import axios from 'axios';
import {createError} from './utils';
const request = axios.create({
    baseURL: 'http://61.190.254.58:8080/',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
        // 'Authorization': 'JWT ' + localStorage.token
    }
});
// 拦截器
request.interceptors.request.use(
    config => {
        config.headers.Authorization = 'JWT ' + localStorage.token;
        return config;
    },
    error => {
        return Promise.reject(error);
    }
);

const handleRequest = (request) => {
    return new Promise((resolve, reject) => {
        request.then(response => {
            if (!response.data) {
                return reject(createError(400, 'no data'));
            }
            resolve(response);
        }).catch(error => {
            const response = error.response;
            reject(response);
        });
    });
};

export default {
    // 获取组织结构信息
    getSiteInfo (params) {
        return handleRequest(request.get('api/user/obunion-trees' + params, params));
    },

    // 获取博主信息
    getBloggerInfo (params) {
        return handleRequest(request.get('api/qask/info/mes/'));
    },

    // 豆瓣API
    getDoubanInfo (params) {
        if ('type' in params && 'id' in params) {
            return handleRequest(request.get(`/api/${params.type}/${params.id}/`, params));
        }
    }
};
