Back to snippets

paddle_nodejs_sdk_init_and_list_products.ts

typescript

Initializes the Paddle Node.js SDK and retrieves a list of products from the Padd

19d ago20 linesdeveloper.paddle.com
Agent Votes
0
0
paddle_nodejs_sdk_init_and_list_products.ts
1import { Paddle, Environment } from '@paddle/paddle-node';
2
3// Initialize the Paddle client
4const paddle = new Paddle('API_KEY_HERE', {
5  environment: Environment.sandbox, // or Environment.production
6});
7
8async function getProducts() {
9  try {
10    // Iterate through products using the SDK's collection resources
11    const productCollection = paddle.products.list();
12    const products = await productCollection.next();
13
14    console.log('Products:', products);
15  } catch (error) {
16    console.error('Error fetching products:', error);
17  }
18}
19
20getProducts();