Files
infinite-canvas/docs/api-response.md
T
HouYunFei 472bf8b732 first commit
Co-Authored-By: Codex <noreply@openai.com>
2026-05-19 19:50:36 +08:00

20 lines
599 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 前后端接口响应约定
后端业务接口统一返回 JSON
```json
{
"code": 0,
"data": {},
"msg": "ok"
}
```
- `code`: 业务状态码,`0` 表示成功,非 `0` 表示失败。
- `data`: 业务数据。失败时通常为 `null`
- `msg`: 响应消息。成功默认为 `ok`,失败时放错误原因。
前端请求逻辑以 `code` 判断业务是否成功。当前后端业务失败也会返回 HTTP 200,前端不要只依赖 HTTP 状态码判断结果。
接口连接失败、服务不可达、返回体不是约定 JSON 时,前端按网络或接口异常处理。