# Catch 401 and redirect

**URL:** <https://forum.codewithmosh.com/t/catch-401-and-redirect/11136>\
**Category:** React Native\
**Created:** [March 8, 2022, 12:54am UTC](https://forum.codewithmosh.com/t/catch-401-and-redirect/11136 "2022-03-08T00:54:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmerli](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cmerli](https://forum.codewithmosh.com/u/cmerli)\
**Post date:** [March 8, 2022, 12:54am UTC](https://forum.codewithmosh.com/t/catch-401-and-redirect/11136/1 "2022-03-08T00:54:10Z")

</div>

Hello,  
I was wondering if anyone knows a way to catch a 401 api response (globally) and redirect back to the login page.

I am looking at the React Native course source code and in my backend I have an access token that expires.  
Once it expires, the API calls return 401. At that point how can I detect it and redirect to the login page?  
If there is not a global way I would have to check `if (response.status === 401)` after **every** call…

Thanks
