As in the subject,
I’m trying to connect to the AddEvent API during a lifecycle hook call. Obviously, this needs to happen quite quickly, but the data types in question are rarely updated en masse, vs one at a time.
Still, while I can connect to other APIs from the lifecycle hooks (I tried a couple of basic free REST APis and received results), connecting to the AddEvent API seems to always lead to this error:
TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11457:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async findEventViaAPI (/Users/robdeskoski/Development/strapi/mtia-disruption-rebuild-backend/dist/src/api/disruption/content-types/disruption/API/addEvent.js:63:22) {
cause: Error [ERR_SOCKET_CONNECTION_TIMEOUT]: Socket connection timeout
at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
at new NodeError (node:internal/errors:399:5)
at internalConnectMultiple (node:net:1098:20)
at Timeout.internalConnectMultipleTimeout (node:net:1637:3)
at listOnTimeout (node:internal/timers:575:11)
at process.processTimers (node:internal/timers:514:7) {
code: 'ERR_SOCKET_CONNECTION_TIMEOUT'
}
I can connect easily via POSTMAN, and I believe I have the correct details in the header:
const response = await fetch(eventsURL, {
method: ‘GET’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: Bearer ${process.env.STRAPI_ADMIN_ADD_EVENT_ACCESS_TOKEN}
},
signal: AbortSignal.timeout(15000) // 15 seconds
})
Any suggestions? Is there anything I’m leaving out here?
Kind regards,
ged12345