Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
nuxtjs-axios-error-handling
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
odanado
February 03, 2020
Programming
430
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
nuxtjs-axios-error-handling
odanado
February 03, 2020
More Decks by odanado
See All by odanado
Vitest Browser Mode への期待 / Vitest Browser Mode
odanado
3
5.8k
@nestjs/bull の活用について
odanado
0
1.6k
クラウド KMS の活用 / TOKYO BLOCKCHAIN TECH MEETUP 2022
odanado
0
1.4k
Vue.observable で状態管理 / vue-observable-state-management
odanado
4
2.2k
ブロックチェーンアプリのトランザクションに対するデータ分析 / PyCon-JP-2019
odanado
0
470
スマートコントラクトに対する既知の攻撃とその対策 / bc.tokyo-21
odanado
0
300
最近のweb3.js事情 / bc.tokyo-19
odanado
2
590
YAPC::Tokyo 2019に スタッフ参加してみて / kichijojipm-18
odanado
1
2.4k
JavaScript + Dockerの知見 / knowledge-of-docker-in-javascript
odanado
9
56k
Other Decks in Programming
See All in Programming
No More NoSuchMethodError
exoego
1
120
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
140
AmebaブログはKMPから卒業します
kmars0605
0
310
dotNET_vulnclicker_intro.pdf
deka_morita
0
160
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
170
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
130
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
5
1.3k
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
1.1k
Event is what happens
moro
2
2.2k
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
220
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
310
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
320
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
It's Worth the Effort
3n
188
29k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
320
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Claude Code のすすめ
schroneko
67
230k
The Cult of Friendly URLs
andyhume
79
7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
560
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
68k
Transcript
@nuxtjs/axios で エラーハンドリング 1 @odan3240
タピオカLT • 初LT (2020年) :tada: 2
自己紹介 • @odan3240 • 株式会社モバイルファクトリー • 最近 ◦ AWS
周り ◦ TypeScript (frontend/backend) ◦ Vue.js 3
@nuxtjs/axios • axios ◦ JavaScript の HTTP クライアントライブラリ •
NuxtJS 向けの axios モジュール ◦ https://github.com/nuxt-community/axios-module 4
エラーハンドリングしたい • API リクエストでエラーが 発生したときにエラーページに飛ばすなどしたい ◦ 公式ドキュメントにあるサンプル ◦ レスポンスが 500
エラーだと /sorry にリダイレクト 5
リダイレクトじゃない挙動にしたい • 例えば ◦ トーストを出す ◦ ページ遷移せずエラーページを表示 • redirect
を呼び出さなければ良い? ◦ NuxtJS のエラーページが表示されてしまう ▪ 内部でエラーがハンドリングされているため ▪ https://github.com/nuxt-community/axios-module/issues/149 6
やりたいこと • 内部のエラーハンドリングをキャンセル • エラーが発生したことを NuxtJS に伝える 7
問題の切り分け • 内部のエラーハンドリングをキャンセル ◦ axios の話 • エラーが発生したことを NuxtJS
に伝える ◦ nuxtjs の話 8
エラーが発生したことを NuxtJS に伝える • NuxtJS の話 • error 関数を呼び出す ◦
https://ja.nuxtjs.org/api/context/ • Nuxt.js と axios のエラーハンドリング周りの話 ◦ https://mya-ake.com/slides/nuxt-axios-error-handling 9
内部のエラーハンドリングをキャンセル • axios でリクエストをキャンセルする方法はあるか? ◦ 「axios promise cancel response」あたりでググる ◦
https://github.com/axios/axios/issues/583 ◦ axios.interceptors.response.use で false を返せば良いっぽい 10
結論 11
まとめ • @nuxtjs/axios で独自のエラーを出す方法を紹介 • 問題を切り分けて立ち向かうの大事 ◦ モジュールの組み合わせで どんどん便利になっている時代なので
• 未解決の issue に解答を示したので 後の人が楽になったはず 12