Skip to content

Instantly share code, notes, and snippets.

View alirezaseif28's full-sized avatar
🏢
Working from home

Alireza alirezaseif28

🏢
Working from home
View GitHub Profile
@douglasabnovato
douglasabnovato / getUser.js
Created December 28, 2021 16:43
promise: fetch, then,catch, finally
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"
@guamacherox
guamacherox / useErrorHandler.js
Last active April 8, 2023 14:46
React Hook for axios error interceptor
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,
@MoienTajik
MoienTajik / iranian-phone-numbers-regex.md
Last active June 10, 2024 22:59
Regex For Iranian Mobile Phone Numbers

Regex For Iranian Phone Numbers

This regex supports all kinds of Iranian mobile phone numbers :

^(\+98|0)?9\d{9}$


Regex Visualized