前端使用
await Fetch(/project/api/project/team/${teamInfo.uuid}/plugin/v1/project
, {method: 'GET',data: { userUUID: userInfo.uuid , timestamp: Date.now()}}) 对后端发起请求
后端接收不到userUUID这个参数
下面是后端代码
export async function getProjectList(request: PluginRequest): Promise<PluginResponse> {
const body = request.body as any
Logger.info('[Plugin] hello ======= 请求成功')
return {
body: {
res: 'xxx',
requestBody: request,
},
}
}
希望得到解决
解决方法建议:
使用GET请求:
GET
请求,前端做法参数需要放在URL的查询字符串中,而不是在data
字段中。例如:GET
请求的查询参数,可以通过request.query
(而不是request.body
)来获取。例如:使用POST请求:
POST
请求,前端做法将参数放在body
中。例如:body
参数:总结
GET
请求,参数放在URL查询字符串中。POST
请求并传递JSON
数据。