javascript - 试图在一次调用中获取 2 个复选框数据以创建 zip 文件。我应该如何在一次服务调用中传递对象中的数组?
问题描述
这是我用单个对象从后端获取对象的地方。
导出函数 downloadFileService(url: string, payload) {
return new Promise(( reject) => {
const getHeaders: object = { ...PostHeaders, body: JSON.stringify(payload) }
fetch(url, getHeaders)
.then((response) => {
if (response.ok) {
const getFileNameFromResponse = response.headers.get("Content-Disposition");
response.blob()
.then((response) => {
const fileName = getFileNameFromResponse.split('/').pop();
const type = 'application/zip';
showXLS(response, fileName, type);
});
} else {
response
.json()
.then((json) => {
const errors = json;
reject(errors ? errors.messageList : []);
});
}
});
});
}
我为选中的复选框创建了一个动作,它只是传递一个对象。我想在一个对象中传递一个数组。
export const downloadFormPDF = (dispatch, getState) => {
const state: IAppState = getState(dispatch);
state.payrollTaxFormReducerState.checked.forEach(item => {
const taxFormItem=state.payrollTaxFormReducerState.formCardList[item];
const downloadPdf=
{selectedCards: taxFormItem.itemID + '~' + taxFormItem.federalId + '~' + taxFormItem.formType + '~' + taxFormItem.year + '~' + taxFormItem.quarter};
// itemID:taxFormItem.itemID,
// federalId: taxFormItem.federalId,
// formType: taxFormItem.formType,
// year: taxFormItem.year,
// quarter: taxFormItem.quarter
downloadFileService('/mascsr/wfn/payrollTaxForms/metaservices/taxforms/downloadpdf', downloadPdf);
console.log("download file", downloadPdf, taxFormItem );
});
}
解决方案
推荐阅读
- python - 数组切片的多个轴上的 Numpy Argmax
- sql - 在 SQL 中搜索不同的 300 个名称表的所有可能组合之间的重复项
- html - 从发送活动参数
- c++ - 库编译期间的Mysql++和mingw32-make错误
- javascript - 如何在 mini-css-extract-plugin 中为 css 修复 hmr?
- image-processing - 将变量传递给类初始化定义python中的nn.Conv2d参数
- javascript - 正则表达式检查 hsl 字符串格式
- vb.net - vb.net 连接访问数据库
- angular - 使用翻译服务和字符串数组应用参数
- asp.net - QuickBooks Online Api 错误“远程服务器返回错误:(400)错误请求”