import parseWeb from "./parse" const baseUrl = "https://forge.educoder.net"; export function run(){ apiParse({name: "projects.repository", data:{project_id:6295, identifier:"pk8f3pmu2"}, success:res=>{ console.log(res); } }) } const apiConfig = { projects: { repository:{url:"{project_id}/repository/{identifier}"} } } function format(str, values) { return str.replace(/\{(.*?)\}/g, function (match, key) { return values[key] || ""; }); } function apiParse({name, data, success, fail, complete}){ let apis = name.split(/\./g); var api = apiConfig; var url = baseUrl; for(var i=0;i{ try{ res.data = parseWeb[name](res.data); success&&success(res); complete&&complete(res); }catch(e){ console.error(e); fail&&fail(e); complete&&complete&&(e); } }, fail: e=>{ fail&&fail(e); complete&&complete(e); } }); }