Log:
{
"message": "Cannot read property 'projectId' of undefined",
"name": "FUNCTION_ERR",
"stack": "TypeError: Cannot read property 'projectId' of undefined\n at getProjects (index.js:36661:35)\n at async index.js:1656:21\n at async asyncMap (index.js:1587:24)\n at async index.js:1608:29\n at async index.js:1076:31",
}
Code:
export const getDataFromJira = async url => {
try {
const response = await api.asUser().requestJira(url);
const result = await response.json();
return result;
} catch (error) {
console.log("getDataFromJira error: ", error);
throw error;
}
};
export const getProjects = async() => {
const response = await getDataFromJira(route`/rest/agile/1.0/board?type=scrum`);
if (!response) return []
let projects = []
for(let board of response.values){
if (!projects.some(item => item.projectKey === board?.location?.projectKey)){
projects.push({
projectId:board.location.projectId,
projectKey:board.location.projectKey,
projectName:board.location.projectName
}
)
}
}
return [...projects].sort((a, b) => a.projectName > b.projectName? 1: -1);
}
PS: Invocation ID: 42b8e5f2-efff-43bb-aca3-d0b6a4407248