I have multiple attachment links and attachment names. This is what the console shows:
The problem is that only the last link and name are shown:
I use this in the template:
<div class="d-inline col-lg-20 col-md-60 col-sm-40" padding="20px" >
<th>Files</th>
<tr>
<div class="d-inline col-lg-20 col-md-60 col-sm-40" padding="20px">
{{attachmentName}}
{{attachmentUrl}}
</div>
</tr>
</div>
This in data:
data() {
return {
selectedFile: "",
progress: 0,
attachmentName: [],
attachmentUrl: [],
};
},
and this in JavaScript:
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items('" + itemId + "')/AttachmentFiles",
method: "GET",
async: false,
headers: { "Accept": "application/json; odata=nometadata" },
success: function (data) {
$(data.value).each(function (i) {
attachments.items.push({
extension: this.FileName.substring(this.FileName.lastIndexOf('.') + 1),
name: this.FileName,
path: this.ServerRelativeUrl
});
attachmentLink = "site.sharepoint.com" + this.ServerRelativeUrl;
attachmentName = this.FileName;
self.attachmentUrl = attachmentLink;
self.attachmentName = attachmentName;
attachments.count++;
console.log("attachments: " + attachmentLink);
console.log("name: " + attachmentName);
});
}
});
The problem is these two lines:
self.attachmentUrl = attachmentLink;
self.attachmentName = attachmentName;
I don't know how to fix this issue because the console.log shows 2 items, while the template only shows the last one. I experimented a bit using for loops but can't get all the attachment links and names into the template.
Any help is appreciated!

