API接口常用参数:路径参数、查询参数、请求参数、响应参数...

一、路径参数:用于标识资源的URL唯一标识符或标识特定资源的属性

https://api.example.com/users/{userID}

//路径参数拼接
1.
export const delete = (id) =>
  defHttp.delete({ url: '/rscheck/v1/person/checkpersonmsg/' + id });
2.
export const delete = (id) =>
  defHttp.delete({ url: `/rscheck/v1/person/checkpersonmsg/${id}` });

//其中,id就是路径参数

二、查询参数:查询参数是在 URL 中通过 ? 后面附加的键值对形式传递的,不同参数之间使用 & 连接

https://api.example.com/search?query=term&page=1&limit=10

export const delete = (params) =>
  defHttp.delete({ url: '/rscheck/v1/person/checkpersonmsg/delete',params });

//其中,params就是查询参数

三、请求头参数(Request Headers): 包含在HTTP请求头部中,用于传递额外的信息,例如授权信息、内容类型等

GET /api/resource HTTP/1.1
Host: example.com
Authorization: Bearer your_access_token
Content-Type: application/json

四、请求体参数(Request Body): 包含在HTTP请求体中,通常用于POST、PUT等请求方法,传递客户端向服务器提交的数据

POST /api/resource HTTP/1.1
Host: example.com
Content-Type: application/json

{
  "key": "value"
}

五、响应头参数(Response Headers): 包含在HTTP响应头部中,用于传递响应的元数据,例如内容类型、缓存控制等

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-cache

六、响应体参数(Response Body): 包含在HTTP响应体中,传递服务器对请求的响应数据

HTTP/1.1 200 OK
Content-Type: application/json

{
  "result": "success"
}

七、授权参数(Authentication Parameters): 用于身份验证,例如用户名、密码、访问令牌等

GET /api/resource HTTP/1.1
Host: example.com
Authorization: Basic base64encoded(username:password)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值