Comments (8)
在 service/api/demo 里面有两个示例:fetchDictionary、fetchDictionaryWithMiddleware
在页面上引入这两个函数
import { fetchDictionary, fetchDictionaryWithMiddleware } from '@/service;
async function testApi() {
const { data: data1 } = await fetchDictionary("管理熵");
if(data1) {
console.log(data1);
}
const { data: data2 } = await fetchDictionaryWithMiddleware("管理熵");
if(data2) {
console.log(data2);
}
}
testApi();
//按照上面的调用一下
from soybean-admin.
666 感谢🙏
from soybean-admin.
请求函数前面加个 await
from soybean-admin.
牛啊~ 可以了。我好好学习 下你的代码
from soybean-admin.
请求函数前面加个await
大佬还有问题想请教下,如果有多个请求地址应该怎么改呢,还有怎么加请求代理呢。
from soybean-admin.
- 在env.development 和 env.production 和env.staging里面添加一个新的请求地址
例如:VITE_HTTP_BAIDU_URL=https://www.baidu.com
2.在src/typings/env.d.ts 添加VITE_HTTP_BAIDU_URL: string; - 在src/service/request/index.ts 创建另一个request,
例如:
export const baiduRequest = createRequest({
baseURL: import.meta.env.VITE_HTTP_BAIDU_URL,
timeout: REQUEST_TIMEOUT
}); - 再去api文件夹下创建对应业务的文件,引入baiduRequest即可
from soybean-admin.
代理的话,需要在vite.config.ts添加配置,参照文档:https://cn.vitejs.dev/config/#server-proxy
from soybean-admin.
- 在env.development 和env.production 和env.staging里面添加一个新的请求地址
例如:VITE_HTTP_BAIDU_URL= https://www.baidu.com
2.在src/typings/env.d.ts 添加VITE_HTTP_BAIDU_URL: string;- 在src/service/request/index.ts创建另一个请求,
例如:
export const baiduRequest = createRequest({
baseURL: import.meta.env.VITE_HTTP_BAIDU_URL,
timeout: REQUEST_TIMEOUT
});- 再去api文件夹下创建对应业务的文件,引入百度请求发酵
谢谢,说的很详细,看明白了。哈哈
from soybean-admin.
Related Issues (20)
- [Bug]: requet的error里面的data类型不正确
- [Bug]: tag圆角与其他组件圆角不统一
- [Refactor] 主题系统设计: 将 theme tokens 和 theme settings 进行合并 HOT 1
- 是否考虑引入unplugin-auto-import插件😁 HOT 2
- 登录界面的默认用户名的密码怎么修改 HOT 2
- [Feature]: 支持全局灰色模式 HOT 2
- 主题色不能自定义,只能在固定的值里面选择 HOT 2
- [Feature]: 提供开关是否应用推荐算法的颜色 HOT 1
- [Bug]: 左侧菜单混合模式布局如果该菜单没有子菜单,并且二级菜单固定的情况下,二级菜单出现空白 HOT 3
- [Bug]: 当用户角色由超级管理员切换至普通用户时,菜单数据未更新至普通用户的菜单
- [Bug]: 当用户角色由超级管理员切换至普通用户时,标签页数据未更新至普通用户的标签页
- [Bug]: 请求返回非json格式时处理异常 HOT 1
- [Feature]: 本地储存可添加前缀 HOT 1
- [Feature]: 分页下增加数据总数如:共100条 HOT 3
- [Bug]: 左侧菜单混合模式布局二级侧边菜单【固定】功能异常 HOT 5
- [Bug]: 布局模式因窗口大小的变化而无法响应式恢复的问题 HOT 4
- [Bug]: 左侧菜单混合模式,收缩折叠图标的文本提示层级低
- [Bug]: 修正编辑表单弹框时的引用类型数据重置问题 HOT 3
- 请问列表详情页该如何创建目录 HOT 2
- [Bug]: 列表页,关闭弹窗时重置数据 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soybean-admin.