Javascript - 获取

Javascript - fetch(Javascript - 获取)
本文介绍了Javascript - 获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编程很陌生,但遇到了一个问题.

Im quite new to programming and I'm stuck with a problem.

这是我的代码:

         fetch('https://feed.tunein.com/profiles/s9615/nowPlaying')
        .then(response => response.json())
        .then(data => console.log(data))

这是我得到的回复:

{
  Header: { Title: 'Radio 1', Subtitle: 'BQL - Muza' },       
  Primary: {
    GuideId: 's9615',
    Image: 'http://cdn-radiotime-logos.tunein.com/s9615q.png',
    Title: 'Radio 1',
    Subtitle: 'Več dobre glasbe'
  },
  Secondary: {
    GuideId: 'o0',
    Image: 'http://cdn-radiotime-logos.tunein.com/s9615q.png',
    Title: 'BQL - Muza',
    Subtitle: 'Radio 1',
    FullScreen: true
  },
  Ads: {
    CanShowAds: true,
    CanShowPrerollAds: true,
    CanShowCompanionAds: false,
    CanShowVideoPrerollAds: false
  },
  Echo: {
    CanEcho: false,
    EchoCount: 0,
    TargetItemId: 's9615',
    Scope: 's9615',
    Url: '',
    FeedTag: 's9615'
  },
  React: {
    CanReact: false,
    TargetItemId: 's9615',
    Scope: 's9615',
    Url: 'https://api.radiotime.com/profiles/me/activities?itemToken=BgwMAAAAAAAAAAAAAAABjyUAAAEMAY8lAAABjyUAAA',
    Reactions: [ [Object], [Object], [Object], [Object], [Object] ]
  },
  Donate: { CanDonate: false },
  Share: { CanShare: true, ShareUrl: 'http://tun.in/selA9' },
  Follow: { Options: [ [Object], [Object] ] },
  Record: { CanRecord: false },
  Classification: {
    ContentType: 'music',
    IsEvent: false,
    IsOnDemand: false,
    IsFamilyContent: false,
    IsMatureContent: false,
    GenreId: 'g141'
  },
  Link: { WebUrl: 'http://www.radio1.si/' },
  Ttl: 18,
  Token: 'eyJwIjpmYWxzZSwidCI6IjIwMjAtMDQtMjRUMjM6NDA6MTAuNzIwNDY4OVoifQ'
}

所以我正在尝试提取存储在 Secondary - Title 中的当前播放歌曲.那么如何提取呢?

So I'm trying to extract the current playing song which is stored in Secondary - Title. So how could i extract it?

感谢您的帮助,也很抱歉我的英语不是我的母语!

Thank you for your help and also sorry about my english since it is not my first language!

推荐答案

代替console.log(data),使用console.log(data.Secondary.Title)

然后您可能想要对数据做一些事情,而不是仅仅将其记录到控制台.

You will probably then want to do something with the data instead of just log it to the console.

这篇关于Javascript - 获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)