Hello!
I’ve got a custom UI Jira plugin with the following manifest.yml app config:
app:
runtime:
name: nodejs18.x
I’ve got a Forge function which handles a form with a file too.
import Resolver from '@forge/resolver';
import api, { route } from "@forge/api";
import FormData from 'form-data';
const resolver = new Resolver();
resolver.define('postOfficeData', async (req) => {
const formData = new FormData();
Object.keys(req.payload).forEach(key => {
formData.append(key, req.payload[key]);
});
const response = await api.fetch('https://jira-plugin-serverless.gyurmatag.workers.dev/add-office', {
method: 'POST',
body: formData
});
if (!response.ok) {
throw new Error(`Error from Cloudflare Worker: ${response}`);
}
return { success: true, message: 'Office data saved successfully.' };
});
The office data that I am sending to the Forge function is like this:
{
"officeName": "hrthrthrt",
"officeRegion": "australia",
"streetAddress": "cvbcvb",
"city": "dfgdfg",
"country": "bdf",
"address": "cvbcvb",
"state": "dfgdfg",
"zipCode": "dfgd",
"electricity": "dfg",
"gas": "dfg",
"water": "dfgd",
"image": {
"path": "Dunder M.png",
"preview": "blob:https://1414a28f-21bf-42ca-8bf2-e4ffc6f7d168.cdn.prod.atlassian-
dev.net/c6c07c00-4c2a-405d-b757-af4240489be1",
"lastModified": 1708253638710,
"lastModifiedDate": "Sun Feb 18 2024 11:53:58 GMT+0100 (közép-európai téli idő)",
"name": "Dunder M.png",
"size": 623999,
"type": "image/png",
"webkitRelativePath": ""
}
}
The endpoint is working totally fine when calling from HTTPie. When I am calling the forge function from the React app it gets me this error:
Error: There was an error invoking the function - source.on is not a function
What is the problem here? I thought the new Nodejs runtime resolved it?
Can somebody please help me? Maybe @AdamMoore ?