我想从这个承诺 return 中提取 ID 值,但是如何呢?
I want to extract the ID value from this promise return but how?
我需要获取新上传到 SharePoint Online 文档库的文件的 ID,以便为其添加权限。
这是返回的数据,箭头指向我需要的 ID:
这是代码和承诺链:
this.state.files.forEach( (file, i) => {
if (file.size <= 10485760) {
var stringId = this.state.Id.toString();
sp.web.getFolderByServerRelativeUrl("/mysitepath/").files.add(file.name, file)
.then(f => {
f.file.getItem().then(async item => {
const lists = sp.web.lists.getByTitle("MyDocLib");
item.update({
JEREF: stringId
}).then(async (myupdate) => {
console.log(myupdate); //this is where I get the log from!
console.log("Metadata update");
const ReadroleDefinition = await sp.web.roleDefinitions.getByName("Read").get();
// await sp.web.lists.getByTitle('MyDocLib')
.items.getById(this.state.JEREF).roleAssignments.add(item, ReadroleDefinition.Id); // This is where I want to add permissions to the newly uploaded file, but can't get the ID!
});
});
使用:
myupdate.item["ID"]
测试结果:
我需要获取新上传到 SharePoint Online 文档库的文件的 ID,以便为其添加权限。
这是返回的数据,箭头指向我需要的 ID:
这是代码和承诺链:
this.state.files.forEach( (file, i) => {
if (file.size <= 10485760) {
var stringId = this.state.Id.toString();
sp.web.getFolderByServerRelativeUrl("/mysitepath/").files.add(file.name, file)
.then(f => {
f.file.getItem().then(async item => {
const lists = sp.web.lists.getByTitle("MyDocLib");
item.update({
JEREF: stringId
}).then(async (myupdate) => {
console.log(myupdate); //this is where I get the log from!
console.log("Metadata update");
const ReadroleDefinition = await sp.web.roleDefinitions.getByName("Read").get();
// await sp.web.lists.getByTitle('MyDocLib')
.items.getById(this.state.JEREF).roleAssignments.add(item, ReadroleDefinition.Id); // This is where I want to add permissions to the newly uploaded file, but can't get the ID!
});
});
使用:
myupdate.item["ID"]
测试结果: