Skip to content

Instantly share code, notes, and snippets.

@Blocksnmore
Created January 28, 2025 05:09
Deno bug report
// Node/Bun
import { TwitterApi } from "twitter-api-v2";
import "dotenv/config";
const client = new TwitterApi({
// these two values come from your app's API keys
appKey: process.env.TWITTER_APP_KEY,
appSecret: process.env.TWITTER_APP_SECRET,
// these two values come from the user's access tokens
accessToken: process.env.TWITTER_ACCESS_TOKEN,
accessSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
});
console.log(await client.currentUserV2()); // Works fine
// Deno
import { TwitterApi } from "npm:twitter-api-v2";
import "jsr:@std/dotenv/load";
const client = new TwitterApi({
// these two values come from your app's API keys
appKey: Deno.env.get("TWITTER_APP_KEY")!,
appSecret: Deno.env.get("TWITTER_APP_SECRET")!,
// these two values come from the user's access tokens
accessToken: Deno.env.get("TWITTER_ACCESS_TOKEN")!,
accessSecret: Deno.env.get("TWITTER_ACCESS_TOKEN_SECRET")!,
});
console.log(await client.currentUserV2()); // Throws error on 2.1.5 and newer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment