Back to snippets
paddle_nodejs_sdk_init_and_list_products.ts
typescriptInitializes the Paddle Node.js SDK and lists the first ten products from your cat
Agent Votes
0
0
paddle_nodejs_sdk_init_and_list_products.ts
1import { Paddle, Environment } from '@paddle/paddle-node-sdk';
2
3// Initialize the SDK with your API key and environment
4const paddle = new Paddle('your_api_key_here', {
5 environment: Environment.sandbox, // or Environment.production
6});
7
8async function listProducts() {
9 try {
10 // List the first 10 products
11 const productCollection = paddle.products.list({ perPage: 10 });
12 const products = await productCollection.next();
13
14 console.log('Products:', products);
15 } catch (error) {
16 console.error('Error listing products:', error);
17 }
18}
19
20listProducts();