^(\+98|0)?9\d{9}$
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
function getUser(userId) { | |
const userData = fetch(`https://api.com/api/user/${userId}`) | |
.then(response => response.json()) | |
.then(data => console.log(data.name)) | |
.catch(error => console.log(error)) | |
.finally(() => /*{ aviso de fim de carregamento }*/) | |
} | |
getUser(1); // "Nome Sobrenome" |
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
import { useEffect } from 'react'; | |
import axios from 'axios'; | |
/** | |
* @description Hooks an axios error interceptor for your react application | |
*/ | |
const useErrorHandler = () => { | |
const errorInterceptor = axios.interceptors.response.use( | |
res => res, |