n8n-nodes-placid
Version:
n8n node to interact with Placid API for creative generation
30 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getImageById = getImageById;
exports.execute = execute;
const n8n_workflow_1 = require("n8n-workflow");
const config_1 = require("../../utils/config");
async function getImageById(executeFunctions, imageId) {
const options = {
method: 'GET',
url: `${config_1.PlacidConfig.getRestUrl(config_1.PlacidConfig.ENDPOINTS.IMAGES)}/${imageId}`,
headers: {
'Accept': config_1.PlacidConfig.HTTP.HEADERS.ACCEPT,
'Content-Type': config_1.PlacidConfig.HTTP.HEADERS.CONTENT_TYPE,
'x-placid-integration': config_1.PlacidConfig.HTTP.HEADERS.PLACID_INTEGRATION,
},
};
return await executeFunctions.helpers.httpRequestWithAuthentication.call(executeFunctions, 'placidApi', options);
}
async function execute(i) {
const imageId = this.getNodeParameter('imageId', i);
if (!imageId) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Image ID is required');
}
const response = await getImageById(this, imageId);
return {
json: response,
pairedItem: { item: i },
};
}
//# sourceMappingURL=get.operation.js.map