45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
/**
|
|
* 测试任务平台 API 请求
|
|
*/
|
|
|
|
const API_KEY = 'b78af0ec58a078105f63aaca3256918f';
|
|
const TASK_NO = 'TASK202601141713525624-01';
|
|
const BASE_URL = 'http://192.168.58.20:4320';
|
|
|
|
async function testApiRequest() {
|
|
console.log('==== 测试任务平台 API 请求 ====\n');
|
|
console.log(`API Key: ${API_KEY}`);
|
|
console.log(`任务号: ${TASK_NO}`);
|
|
console.log(`URL: ${BASE_URL}/api/external/product-assets?taskNo=${TASK_NO}\n`);
|
|
|
|
try {
|
|
const response = await fetch(`${BASE_URL}/api/external/product-assets?taskNo=${TASK_NO}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'X-API-Key': API_KEY,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
console.log(`状态码: ${response.status}`);
|
|
console.log(`状态文本: ${response.statusText}\n`);
|
|
|
|
if (!response.ok) {
|
|
const errorText = await response.text();
|
|
console.log('错误响应:');
|
|
console.log(errorText);
|
|
return;
|
|
}
|
|
|
|
const data = await response.json();
|
|
console.log('✅ 请求成功!');
|
|
console.log('响应数据:');
|
|
console.log(JSON.stringify(data, null, 2));
|
|
} catch (error) {
|
|
console.error('❌ 请求失败:');
|
|
console.error(error);
|
|
}
|
|
}
|
|
|
|
testApiRequest();
|