feat(api): 添加 http 工具模块并更新相关文件
- 新增 http 工具模块,用于创建带有基础 URL 的 axios 实例 - 更新 package.json,添加 axios 依赖 - 调整 addClient.js 文件的格式
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module.exports = (ctx) => {
|
||||
|
||||
|
||||
|
||||
module.exports = (ctx) => {
|
||||
ctx.body = {
|
||||
message: 'Example POST API',
|
||||
data: ctx.request.body
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"author": "kubbo",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"dotenv": "^16.4.7",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"koa": "^2.15.4",
|
||||
@@ -18,4 +19,4 @@
|
||||
"koa-router": "^13.0.1",
|
||||
"nodemon": "^3.0.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
utils/http.js
Normal file
3
utils/http.js
Normal file
@@ -0,0 +1,3 @@
|
||||
require("dotenv").config();
|
||||
const { default: axios } = require("axios");
|
||||
module.exports = (baseURL = process.env.BASE_URL) => axios.create({ baseURL: BASE_URL });
|
||||
Reference in New Issue
Block a user