Skip to content

Instantly share code, notes, and snippets.

export default function Home() {
function refresh(e) {
e.preventDefault();
window.location.reload();
}
const {data, error} = useSWR("api/data", fetcher)
if (error) return "An error has occurred.";
if (!data) return "Loading...";
return (
<div className={styles.container}>
import Redis from 'ioredis'
let redis = new Redis(process.env.REDIS_URL)
export default async (req, res) => {
let start = Date.now();
let cache = await redis.get("cache")
cache = JSON.parse(cache)
let result = {}
if (cache) {
const RateLimiter = require('async-ratelimiter')
const Redis = require('ioredis')
const { getClientIp } = require('request-ip')
const rateLimiter = new RateLimiter({
db: new Redis("YOUR_REDIS_URL"),
max: 1,
duration: 5_000
})
import '../styles/globals.css'
import {
ApolloClient,
ApolloProvider, createHttpLink, InMemoryCache,
} from "@apollo/client";
const link = createHttpLink({
uri: "https://graphql-us-east-1.upstash.io/",
headers: {
Authorization: "Bearer YOUR_ACCESS_TOKEN",
},
import Head from 'next/head'
import styles from '../styles/Home.module.css'
import {
gql, useQuery,
} from "@apollo/client";
import React from "react";
const GET_COIN_LIST = gql`
query {