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
580
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
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
380
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
190
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.7k
Kotlinの15年とServer-Side Kotlin
n_takehata
1
160
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
370
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
470
AWSに止められる覚悟してますか?
morizo_1984
2
550
ジョジョの世界をXRで再現する
mofurune
0
180
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
450
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
35k
Performance Optimization With LLMs
xleitix
0
200
パスワード再設定メールのURLについて知っておこう
uyuki234
0
180
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
640
We Are The Robots
honzajavorek
0
400
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
740
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
760
Visualization
eitanlees
153
17k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
Automating Front-end Workflow
addyosmani
1370
210k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
530
Utilizing Notion as your number one productivity tool
mfonobong
4
620
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