Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Cache is still at 0 #246

Open
Dupflo opened this issue Apr 28, 2021 · 1 comment
Open

Cache is still at 0 #246

Dupflo opened this issue Apr 28, 2021 · 1 comment

Comments

@Dupflo
Copy link

Dupflo commented Apr 28, 2021

import axios from 'axios'
import { setupCache } from 'axios-cache-adapter'

// Create axios-cache-adapter instance
const cache = setupCache({
maxAge: 5 * 60 * 1000,
})

const api = axios.create({
adapter: cache.adapter,
})

export const getTimeline = async () => {
let tweets = {}

const response = await api({
url:
'https://api.twitter.com/2/users/106699049/tweets?exclude=retweets,replies',
headers: {
Authorization: Bearer ${process.env.TWITTER_API_KEY},
},
method: 'get',
})

const length = await cache.store.length()

console.log('Cache store length:', length)

tweets = response.data.data

return tweets
}

@Dupflo Dupflo closed this as completed Apr 28, 2021
@Dupflo Dupflo reopened this Apr 28, 2021
@Drakolis
Copy link

@Dupflo you have query params, you can check this issue out #117
you need to enable caching for requests with queries.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants