smallpath / blog

前后端分离+服务端渲染的博客系统. 基于Vue2、Koa2、MongoDB、Redis

Home Page:https://smallpath.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api.js 这段代码不太理解,import api from 'create-api' ,这个引用在那里

wwb568109135 opened this issue · comments

import api from 'create-api'

const prefix = ${api.host}/api

const store = {}

export default store

store.fetch = (model, query) => {
const target = ${prefix}/${model}
return api.axios.get(target, { params: query }).then((response) => {
const result = response.data
return result
})
}

通过webpack alias在客户端和服务端分别导入不同的请求库, 客户端请求库为自造ajax轮子, 服务端为伪造成ajax库的数据库查询逻辑

相应两篇文章在这:

谢谢 之前一直没有找到这个create-api他的引用,现在知道了,谢谢楼主!