request方法中需要传入自定义的一个TaskModel,和pageNum,pageSize参数作为入参,怎么转化传给request的入参data,TaskModel结构如下:
class TaskModel {
title:string;
num:number;
otherModel:OtherModel;
adition:Array<string>;
}
class OtherModel {
id:string;
time:string;
}
export function requestTaskWithModel(taskModel:TaskModel): Promise<null> {
return request('/task/tasks','POST',taskModel????)
.then(response => null)
.catch((err: BusinessError) => {
throw new Error(`Error code: ${err.code}, message: ${JSON.stringify(err)}`);
});
}
可以通过request里面的HttpRequestOptions配置extraData,参考文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-http-V5\#request-1
参考demo: