Display Json issue

products
javascript
authentication

#1

I want to see the result. Where am I wrong?

—Javascript—

const MoltinGateway = require('@moltin/sdk').gateway

const Moltin = MoltinGateway({
client_id: XXX
})

Moltin.Products.All().then(products => {
// Do something
console.log(Products.All.name);
})

#2

Hi there,

To console log the full product listing response from the API into your browser console window you would need to do the following:

console.log(products);

Thanks,
Adam


#3

const MoltinGateway = require(’@moltin/sdk’).gateway

const Moltin = MoltinGateway({
client_id: XXX
})

Moltin.Products.All().then(products => {
// Do something
console.log(products);
	
})

BUT DON?T WORK


#4

Hi @MirkoVona

How are you running the JavaScript above? Are you using it client or server side?

If you’re using it server-side, you should see the console.log inside your terminal.

I imagine you’re running node file.js? You’ll need to have the @moltin/sdk package installed via Yarn/npm in order to use requirejs


#5

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.