fetch调用后如何获取id?

How to get the id after fetch call?

我想通过 gettng 来定位 id,但我似乎只得到全部数据,如果我控制台记录它,我会看到 id 等等,但我不知道如何只在控制台日志中打印 id 这是一个示例代码:

fetch('http://localhost:5000/get/' + f)
.then((response) => response.json())
.then((data) => {
  console.log(data)

data 对象具有以下结构:

data = {
    data: [{
      id: some value,
      // some other key-value pairs
    }],
    // some other key-value pairs
}

data 是一个 JSON 对象,其键也名为 data。此键引用一个数组,该数组存储 JSON 个对象,其中包含 id.

答案是data.data[0].id

这就是它令人困惑的原因。