-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
const axios = require('axios'); | ||
|
||
// 假設這是你的業務邏輯函數 | ||
function runBusinessLogic() { | ||
function runBusinessLogic(input) { | ||
// 這裡可以放置你的業務邏輯 | ||
return '程式碼運行順利!'; | ||
return `處理的結果: ${input}`; | ||
} | ||
|
||
// 進行簡單測試 | ||
try { | ||
const result = runBusinessLogic(); | ||
console.log(result); | ||
process.exit(0); // 正常退出 | ||
} catch (error) { | ||
console.error('測試失敗:', error); | ||
process.exit(1); // 當有錯誤發生時返回非零退出碼 | ||
} | ||
// 從 API 獲取測試數據 | ||
axios.get('https://api.example.com/test-data') | ||
.then(response => { | ||
const testData = response.data; | ||
try { | ||
const result = runBusinessLogic(testData); | ||
console.log(result); | ||
process.exit(0); // 正常退出 | ||
} catch (error) { | ||
console.error('測試失敗:', error); | ||
process.exit(1); // 當有錯誤發生時返回非零退出碼 | ||
} | ||
}) | ||
.catch(error => { | ||
console.error('無法獲取測試數據:', error); | ||
process.exit(1); // 當有錯誤發生時返回非零退出碼 | ||
}); |