I have an extension on devops azure, and I 'm newbie in Javascript by the way. I wrote an function to get the name of task after fetch its id from server:
dataService.getDocument("registryKey").then((doc) => {
let authenToken = doc.value[doc.count - 1];
fetch('https://52.221.253.35/api/timelog'+query, {
method: 'GET',
headers:{
'Authentication': authenToken
}
}).then((resp) => resp.json()).then(function (data) {
let index = 1;
let body = "";
// foreach the data and i call VSS Http to get work item 's detail
data.forEach(async function f(item) {
let result = await witClient.getWorkItems(item.TaskId, ["System.Id", "System.Title"]);
body+="<p>"+result['System.Title']+"</p>"
$("#table-body").html(body);
});
but when it runs, it throws an error: Uncaught (in promise) TypeError: n.join is not a function
What is wrong here? Thank you for your comment.
Try this:
let result = await witClient.getWorkItems([item.TaskId], ["System.Id", "System.Title"]);
body+="<p>"+result['System.Title']+"</p>"
$("#table-body").html(body);
});
Note the square brackets around the first parameter.