This topic was automatically generated from Slack. You can find the original thread here.
when i run the following script I get a message in the console Logs “HTTP interface can not respond to this request, check http.customResponse setting”
Can you check this script and advise why?
import { axios } from "@pipedream/platform";
import crypto from "crypto";
export default defineComponent({
props: {
http: {
type: "$.interface.http",
customResponse: true,
},
secure_token: {
type: "string",
label: "Secure Token",
},
},
async run({ event }) {
console.log("Event:", event); // Log the entire event object
const { method, query } = event;
console.log("Method:", method); // Log the HTTP method
console.log("Query:", query); // Log the query parameters
if (method === "GET" && query.crc_token) {
const crc_token = query.crc_token;
const hmac = crypto.createHmac("sha256", this.secure_token);
hmac.update(crc_token);
const value = hmac.digest("base64");
const response = {
status: 200,
body: {
crc_response: value,
},
headers: {
"content-type": "application/json",
},
};
console.log("Sending response:", response); // Log the response
try {
this.http.respond(response);
} catch (error) {
console.log("Error in sending response:", error); // Log any errors
}
} else {
const errorResponse = {
status: 400,
body: {
error: "Invalid request",
},
headers: {
"content-type": "application/json",
},
};
console.log("Sending error response:", errorResponse); // Log the error response
try {
this.http.respond(errorResponse);
} catch (error) {
console.log("Error in sending error response:", error); // Log any errors
}
}
},
});