resolver.define('createIssue', async () => {
// try {
// const bodyData = {
// fields: {
// project: {
// key: 'FL', // Project key in the target Jira instance
// },
// summary: 'Issue has been created', // Issue summary
// issuetype: {
// name: 'Task',
// },
// description: 'This issue is related to a Forge integration', // Issue description
// },
// };
// const authToken = Buffer.from(
// 'ankit.kharola@google.com:my-auth-token'
// ).toString('base64');
// const response = await fetch(`${targetJiraUrl}/rest/api/2/issue`, {
// method: 'POST',
// headers: {
// 'Accept': 'application/json',
// 'Content-Type': 'application/json',
// Authorization: `Basic ${authToken}`,
// },
// body: JSON.stringify(bodyData),
// });
// console.log('Response Status:', response.status);
// console.log('Response OK:', response.ok);
// if (response.ok) {
// const issue = await response.json(); // Parse JSON on success
// console.log('Created issue:', issue);
// return issue;
// }
// const errorBody = await response.text(); // Handle errors
// console.error('Error response body:', errorBody);
// try {
// const errorDetails = JSON.parse(errorBody);
// console.error('Parsed error details:', errorDetails);
// } catch (parseError) {
// console.error('Failed to parse error response as JSON:', parseError);
// }
// throw new Error(`Failed to create issue: ${response.statusText}`);
// } catch (error) {
// console.error('Error during issue creation process:', error.message);
// throw new Error('Failed to create issue in the target Jira instance');
// }
// }); the issue is being created but when i try to use await repsonse.json() or await response.text() the code block goes to catch block
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.