n8n-nodes-netbox
Version:
n8n community node for NetBox API integration with comprehensive DCIM, IPAM, Virtualization, Circuits, Wireless, and data center management operations
30 lines (29 loc) • 800 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatResponse = formatResponse;
/**
* Format API response based on NetBox's typical response format
*/
function formatResponse(response) {
if (!response) {
return [{ json: {} }];
}
// If the response is an array, map each item to a node
if (Array.isArray(response)) {
return response.map((item) => ({
json: item,
}));
}
// If the response has results property (paginated response)
if (response.results && Array.isArray(response.results)) {
return response.results.map((item) => ({
json: item,
}));
}
// Otherwise, treat as a single response
return [
{
json: response,
},
];
}