Hi there!
I’m using Netlify functions and square api to fetch data.
listCatalog()
works just fine, but when I pass an argument (listCatalog(“ITEM”)
), I get a 500 status code error.
Here’s my Netlify function:
const square = require(‘square’)
const handler = async (event) => {
const client = new square.Client({
timeout: 3000,
environment: square.Environment.Sandbox,
accessToken: process.env.SQUARE_ACCESS_TOKEN
})
try {
const response = await client.catalogApi.listCatalog(“ITEM”)
console.log(response.result)
return {
statusCode: 200
}
} catch (error) {
return { statusCode: 500, body: error.toString() }
}
}
module.exports = { handler }