Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Can';t使用易趣在React中查找高级API显示价格数据_Node.js_Reactjs_Ebay Api - Fatal编程技术网

Node.js Can';t使用易趣在React中查找高级API显示价格数据

Node.js Can';t使用易趣在React中查找高级API显示价格数据,node.js,reactjs,ebay-api,Node.js,Reactjs,Ebay Api,我正在使用Finding Advanced API从eBay成功查询数据。我正在映射要显示在页面上的项目。我可以显示查询项目的标题和图像。然而,当我试图降低嵌套在数组中的价格时,我遇到了麻烦 数据如下所示: { itemId: [ "120901386991" ], title: [ "1952 Topps Mickey Mantle Chase Card Box 18 packs 5 1950s or 1960's cards per box" ], globalId: [ "EBAY-

我正在使用Finding Advanced API从eBay成功查询数据。我正在映射要显示在页面上的项目。我可以显示查询项目的标题和图像。然而,当我试图降低嵌套在数组中的价格时,我遇到了麻烦

数据如下所示:

   {
itemId: [
"120901386991"
],
title: [
"1952 Topps Mickey Mantle Chase Card Box 18 packs 5 1950s or 1960's cards per box"
],
globalId: [
"EBAY-US"
],
subtitle: [
"3 BX LOT. 1 VINTAGE PK PER 25 BOXES* LOOK 4 1952 MANTLE"
],
primaryCategory: [
{
categoryId: [
"213"
],
categoryName: [
"Baseball Cards"
]
}
],
secondaryCategory: [
{
categoryId: [
"156521"
],
categoryName: [
"Vintage Non-Sport Cards"
]
}
],
galleryURL: [
"https://thumbs4.ebaystatic.com/m/m1mtMB65mAApWQ2EhJy4qWA/140.jpg"
],
viewItemURL: [
"https://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=2&toolid=10044&campid=5338164673&customid=watchbask&lgeo=1&vectorid=229466&item=120901386991"
],
paymentMethod: [
"PayPal"
],
autoPay: [
"true"
],
location: [
"USA"
],
country: [
"US"
],
shippingInfo: [
{
shippingServiceCost: [
{
@currencyId: "USD",
__value__: "0.0"
}
],
shippingType: [
"Free"
],
shipToLocations: [
"Worldwide"
],
expeditedShipping: [
"false"
],
oneDayShippingAvailable: [
"false"
],
handlingTime: [
"1"
]
}
],
sellingStatus: [
{
currentPrice: [
{
@currencyId: "USD",
__value__: "118.0"
}
],
convertedCurrentPrice: [
{
@currencyId: "USD",
__value__: "118.0"
}
],
sellingState: [
"Active"
],
timeLeft: [
"P13DT19H16M11S"
]
}
],
listingInfo: [
{
bestOfferEnabled: [
"false"
],
buyItNowAvailable: [
"false"
],
startTime: [
"2012-04-23T16:52:17.000Z"
],
endTime: [
"2019-10-23T16:52:17.000Z"
],
listingType: [
"FixedPrice"
],
gift: [
"false"
],
watchCount: [
"444"
]
}
],
returnsAccepted: [
"false"
],
condition: [
{
conditionId: [
"1000"
],
conditionDisplayName: [
"Brand New"
]
}
],
isMultiVariationListing: [
"false"
],
pictureURLLarge: [
"https://i.ebayimg.com/00/s/NTAwWDMxNA==/z/sT8AAOSw62VZv9qQ/$_1.JPG"
],
topRatedListing: [
"false"
]
},
我用易趣上的“卡片”符号传递道具。我还可以在谷歌开发工具中看到这些道具

因此,虽然我可以在react中使用
{card.title}
成功显示标题

当我使用
{card.sellingStatus.convertedCurrentPrice}
时,我得到以下错误:

TypeError:无法读取未定义的属性“convertedCurrentPrice”

我尝试了一些其他的变化,但似乎没有任何效果

注:这里是我试图显示的“卡片”组件(此代码显示了我用于定价的另一种替代方案)

  const Card = props => {
  const { card } = props;
  return (
    <div className="col-md-3">
      <div className="card">
        <div className="card-block">
          {/* <h5 className="card-title">{card.title}</h5> */}
          <div className="mx-auto" style={{ width: 200 }}>
            <img
              src={card.pictureURLLarge}
              style={{
                width: 190,
                height: 200
              }}
              className="img-responsive"
              alt="..."
            />
          </div>
          <div className="card-body">
            <h2>{card.sellingStatus.convertedCurrentPrice["__value__"]}</h2>
          </div>
        </div>
      </div>
    </div>
const Card=props=>{
const{card}=道具;
返回(
{/*{card.title}*/}
{card.sellingStatus.convertedCurrentPrice[“\uuuuuuuuuuuuuuuuuuuuuuuuuuuu值”]}
另外请注意,这里是我的map函数

 {card_list.map(item => (
                      <Card key={item.id} card={item} />
{card\u list.map(项=>(

我在这里遗漏了什么吗?

正如您所看到的sellingStatus是一个数组。因此您必须像这样映射或获取值

card.sellingStatus['convertedCurrentPrice]["__value__"]

因为您不需要多个


这样它就不会在承诺解决时抛出错误。

谢谢Udit,我正在尝试这样的
{card.sellingStatus[“convertedCurrentPrice”][“\uuuuuu value\uuuuuuuu”]}
并且仍然存在相同的问题。您可以从api调用中发布一个小提琴或至少一个对象吗?抱歉,暂时停止工作,这有帮助吗(这是ebay的示例输出)通过使用上面链接的响应,我可以使用response.item.map(card=>({card.sellingStatus.convertedCurrentPrice}))获取数据;是的,由于某些原因,我正在提取的数据返回的格式与我在问题开始时显示的略有不同,带有嵌套数组。我可以稍后发布完整的输出。你确定sellingStatus是数组吗?这里它看起来像个对象。这是我从api获得的输出,我无法访问pastebin,你能添加到que吗stion?好的,我在问题的开头贴出了几乎所有的东西似乎都在一个数组中,有趣的api响应。
card.sellingStatus[0].currentPrice[0]["__value__"];
card.sellingStatus && card.sellingStatus[0].currentPrice[0]["__value__"];