JS POST 不执行 fetch(url
,直接到 catch(ex){FR.Logger.error(ex);FR.Msg.toast(FR.i18nText('Custom')+'JS'+FR.i18nText('Error')+' : '+ex.message);}}).createDelegate(this, [], 0).apply(this, arguments)
代码如下
debugger;
const url = 'http://***';
const username = '*****';
const password = '*****';
const Body = {
"approver": "N8181820",
"factory": "2022",
"name_of_parts": "ame_of_parts",
"document_number": "NNNNN",
"machine_tool_type": "machine_tool_type",
"new_version_number": "w_version_nu",
"program_name": "program_name",
"part_drawing_number": "part_drawin",
"auditor": "N8181820",
"issuing_nature": "issuing_nature",
"list": [
{
"sequence_number": "111111111",
"field1": "12",
"modify_type": "22",
"field3": "21321",
"field2": "123",
"field5": "3213",
"field4": "321312"
}
],
"applicant": "N8181820",
"program_number": "ogram_number",
"attachment": "attachment",
"procedure_description": "edure_descrip",
"application_time": "2024-06-23",
"machine_number": "machine_numbe",
"tzid": "10001",
"group_counter": "group_counter",
"original_version_number": "ginal_versio",
"operation_number": "operation_numbe",
"material_code": "material_code"
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic ' + btoa(username + ':' + password)
},
body: JSON.stringify(Body)
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
return response.json();
})
.then(data => {
// 处理响应数据
console.log(data);
})
.catch(error => {
// 处理错误
console.error(error);
});