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 => request(opt, params);
  });
  return api;
}
