Skip to content

Instantly share code, notes, and snippets.

View kassiogluten's full-sized avatar
🏠
Working from home

Kassio Alcantara kassiogluten

🏠
Working from home
View GitHub Profile
@kassiogluten
kassiogluten / handleErrors.ts
Created January 23, 2024 21:10
Valida erros de apis, e retorna em string
export function handleError(error: unknown): string {
let message: string;
if (error instanceof Error) {
console.log("if");
message = error.message;
} else if (error && typeof error === "object" && "message" in error) {
console.log("if");
message = String(error.message);
} else if (error && typeof error === "object" && "msg" in error) {
console.log("if");
@kassiogluten
kassiogluten / phoneNumberFormat.ts
Created January 23, 2024 20:19
Extrair informações de um numero internacional
import { PhoneNumberUtil } from "google-libphonenumber";
export function manualParsePhoneNumber(
input: string,
country: string = "BR"
): any {
const phoneUtil = PhoneNumberUtil.getInstance();
try {
const parsedNumber = phoneUtil.parse(input, country);
const countryCode = String(parsedNumber.getCountryCode());
https://github.com/ults-io/vscode-react-javascript-snippets/blob/HEAD/docs/Snippets.md
rafc import React from 'react'
export const $1 = () => {
return <div>$0</div>
}
imrse→ import React, { useState, useEffect } from 'react'
@kassiogluten
kassiogluten / anotacoes.txt
Last active June 18, 2023 01:15
anotacoes
// Verificar ambiente
{process.env.NODE_ENV === "development"}
// Limpar CPF CNPJ PHONE (deixa apenas números)
.replace(/\D/g, "")
// axios params
axios.get('https://www.example.com/search', {
params: {
q: 'axios',