Reactjs 我想从这个承诺返回中提取ID值,但是如何提取?
我需要获取新上载到SharePoint Online文档库的文件的ID,以便为其添加权限。 以下是返回的数据,箭头指向我需要的ID: 以下是代码和承诺链:Reactjs 我想从这个承诺返回中提取ID值,但是如何提取?,reactjs,sharepoint-online,spfx,Reactjs,Sharepoint Online,Spfx,我需要获取新上载到SharePoint Online文档库的文件的ID,以便为其添加权限。 以下是返回的数据,箭头指向我需要的ID: 以下是代码和承诺链: this.state.files.forEach( (file, i) => { if (file.size <= 10485760) { var stringId = this.state.Id.toString(); sp.web.getFolderByServerRe
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!
});
});
this.state.files.forEach((文件,i)=>{
if(file.size){
f、 file.getItem().then(异步项=>{
const list=sp.web.lists.getByTitle(“MyDocLib”);
项目.更新({
杰里夫:斯特林吉德
})。然后(异步(myupdate)=>{
console.log(myupdate);//这是我获取日志的地方!
日志(“元数据更新”);
const ReadroleDefinition=wait sp.web.roleDefinitions.getByName(“Read”).get();
//等待sp.web.lists.getByTitle('MyDocLib')
.items.getById(this.state.JEREF).roleasignments.add(item,ReadroleDefinition.Id);//我想在这里向新上载的文件添加权限,但无法获取Id!
});
});
使用:
测试结果:
这不就是item.Id吗?请看一下文档:
myupdate.item["ID"]