{thi-6ren">
gpt4 book ai didi

javascript - 报错 "Type ' void' is not assignable to type 'ReactNode' "

转载 作者:行者123 更新时间:2023-11-29 20:38:07 28 4
gpt4 key购买 nike

我正在尝试调用这个函数

    compatiblelist() {
CompatibleDevicesAPI().then(
response => {this.getCompatList(response)}
);

}

每当我调用 {this.compatiblelist()} 时都会出错

CompatibleDevicesAPI() 函数如下所示

export default function CompatibleDevicesAPI() {
return fetch("https://abc/jjklsd/jlasd").then((res) => {
let results = [];
for(var i=0;i<res.response.docs.length;i++){
let obj ={
'compManufacturer': res.response.docs[i].comanufacturer,
'comDisplayName': res.response.docs[i].comDisplayName ,
'id' : res.response.docs[i].id,
}
results.push(obj);
}
return results;
}).catch((error) => {
let results = [];
results.push({
'comManufacturer': 'error',
'comDisplayName': error
})
return results;
});
}

最佳答案

我认为你只需要添加返回

.then( response => {return this.getCompatList(response)} )

关于javascript - 报错 "Type ' void' is not assignable to type 'ReactNode' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56213991/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com