/*
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2020-10-30 11:21:59
 * @LastEditors: 无尘
 * @LastEditTime: 2020-11-19 15:54:40
 */
import { request } from '@/utils/request.js';

export default function getFetch(api, baseUrl) {
  api = api || {};
  let keys = Object.keys(api);
  keys.forEach(key => {
    let opt = api[key];
    if (typeof opt === 'string') opt = { url: opt };
    opt.url = `${baseUrl}${opt.url}`;
    api[key] = (params, requestConfig) => request(opt, params, requestConfig);
  });
  return api;
}
