Skip to content

Instantly share code, notes, and snippets.

View prince272's full-sized avatar
💭
🧐

Prince Owusu prince272

💭
🧐
View GitHub Profile
@prince272
prince272 / axios-catch-error.js
Created January 10, 2021 00:45 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
using LinqKit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@prince272
prince272 / axiosAuth.js
Last active August 11, 2022 19:30
Inspired by @jetbridge, the http-client.js stores, clears, transmits and automatically refresh JWT authentication tokens. Supports both localstorage and cookie storage.
import Cookies from 'js-cookie';
import { BehaviorSubject } from 'rxjs';
// How to Set Expiry Time (TTL) for LocalStorage With Javascript
// source: https://www.sohamkamani.com/blog/javascript-localstorage-with-ttl-expiry
const createLocalStorage = () => {
return {
get: (key) => {
const itemStr = localStorage.getItem(key);
public class EmailAccount
{
public string Username { get; set; } = default!;
public string Password { get; set; } = default!;
public string Email { get; set; } = default!;
public string DisplayName { get; set; } = default!;
}