@hubspot/cms-lib
Advanced tools
Comparing version 1.1.10-beta.0 to 2.0.0-beta.2
@@ -10,12 +10,32 @@ const path = require('path'); | ||
const functionBody = ` | ||
exports.main = ({ accountId, body, params }, sendResponse) => { | ||
console.log('Your HubSpot account ID: %i', accountId); | ||
sendResponse({ | ||
statusCode: 200, | ||
body: { | ||
message: 'Hello, world!', | ||
}, | ||
}); | ||
// Require axios library to make API requests | ||
const axios = require('axios'); | ||
// This function is executed when a request is made to the endpoint associated with this file in the serverless.json file | ||
exports.main = ({ accountId }, sendResponse) => { | ||
// Use axios to make a GET request to the search API | ||
axios | ||
.get('https://api.hubapi.com/contentsearch/v2/search', { | ||
params: { | ||
portalId: accountId, | ||
term: 'searchTerm', | ||
}, | ||
}) | ||
.then(function(response) { | ||
// Handle success | ||
// The console.log statement will appear in the terminal when you run the hs logs CMS CLI command | ||
// For full documentation, see: developers.hubspot.com/docs/cms/developer-reference/local-development-cms-cli#logs | ||
console.log('Data received from the search API:', response.data); | ||
// sendResponse is what you will send back to services hitting your serverless function | ||
sendResponse({ body: { response: response }, statusCode: 200 }); | ||
}) | ||
.catch(function(error) { | ||
// Handle error | ||
// This is a simple example; error handling typically will be more complicated. | ||
// For more information on error handling with axios, see: https://github.com/axios/axios#handling-errors | ||
sendResponse({ body: { error: error.message }, statusCode: 500 }); | ||
}); | ||
}; | ||
`; | ||
`.trim(); | ||
@@ -22,0 +42,0 @@ function createEndpoint(endpointMethod, filename) { |
{ | ||
"name": "@hubspot/cms-lib", | ||
"version": "1.1.10-beta.0", | ||
"version": "2.0.0-beta.2", | ||
"description": "Library for working with the HubSpot CMS", | ||
@@ -34,3 +34,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "5a9b738f08e63bea7bd274ad68257dacafbe113d" | ||
"gitHead": "3a35a937f255ad1934694aca25cc96a351713f2f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
207161
6789
1