結果 : how to handle api errors in javascript