Skip to content

Instantly share code, notes, and snippets.

View joedooley's full-sized avatar

Joe Dooley joedooley

  • Florida
  • 20:19 (UTC -05:00)
View GitHub Profile
@nvbn
nvbn / App.js
Last active August 29, 2023 13:39
Hooks with classes
import React from "react";
import Counter from "./Counter";
const App = () => {
return (
<div className="App">
<Counter initialCount={100} />
</div>
);
};
@nikasepiskveradze
nikasepiskveradze / http.ts
Created January 8, 2021 17:06
Http client example with TS and RXJs
import {Observable, of} from "rxjs";
import {catchError, map} from "rxjs/operators";
import {ajax} from "rxjs/ajax";
class Http {
public get<T extends Object = Object>(url: string, headers?: any): Observable<T> {
return ajax.get.apply(undefined, [`${url}`, headers]).pipe(catchError(this.catchError), map(this.map));
}
public post<T extends Object = Object>(url: string, body?: any, headers?: any): Observable<T> {
@sindresorhus
sindresorhus / esm-package.md
Last active November 21, 2025 09:14
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@joedooley
joedooley / _middleware.ts
Created August 2, 2022 15:42 — forked from alexjtupper/_middleware.ts
@auth0-nextjs getSession compatible with Next.js Edge Runtime (middleware)
import { getSession } from './getMiddlewareSession';
import { NextMiddleware } from 'next/server';
const middleware: NextMiddleware = async (req, event) => {
try {
let session = await getSession(req)
console.log(session.user.name)
} catch (err) {
console.error(err)
}