我正在制作一个应用程序,其中我在本机反应中调用 API 端点但我收到此错误但在网络应用程序中(它通过反应完成)它没有显示任何错误,这是反应中的网络应用程序代码打字稿
try {
let result: any;
const criteriaWithNoFile = {
content: filterCriteria.content ? filterCriteria.content.trim() : '',
filterLimit: filterCriteria.filterLimit,
sorting: filterCriteria.sorting,
contractionOption: filterCriteria.contractionOption,
contentId: filterCriteria.contentId,
url: filterCriteria.url ? filterCriteria.url.trim() : ''
}
if (localStorage.getItem('currentUserToken')) {
dispatch({
type: LOADER,
payload: true
});
const formData = new FormData();
const jsonFilterCriteria = JSON.stringify(criteriaWithNoFile);
const blobFilterCriteria = new Blob([jsonFilterCriteria], {
type: 'application/json'
});
formData.append("filterData", blobFilterCriteria);
formData.append("filterFile", filterCriteria.selectedFile);
console.log('FormData', formData);
try {
result = await authAxios.post(`${process.env.REACT_APP_BASE_URL}/filter`, formData, {
headers: {
'Content-Type': 'multipart/mixed'
}
});
这是我在 React Native 中尝试的代码
const filterData = {
content: '',
filterLimit: 1000,
sorting: 'NATURAL',
contractionOption: 'LEAVE_CONTRACTION',
contentId: '',
url:
'https://stackoverflow.com/questions/37552973/get-the-time-zone-with-react-native',
};
const data = new FormData();
const jsonFilter = JSON.stringify(filterData);
const blobFilter = new Blob([jsonFilter], {
type: 'application/json',
});
任何人都可以帮助我我做错了什么......
临摹微笑
相关分类