[英]How to read object URI(JSON FILE) from json file
I have a JSON FIle and In this JSON file there is an object URI and this URI contain a JSON file and I am trying to fetch data from URI JSON file but I could not I also attached my code and JSON file 我有一个JSON文件,并且在此JSON文件中有一个对象URI,并且此URI包含一个JSON文件,我正在尝试从URI JSON文件中获取数据,但我无法同时附加我的代码和JSON文件
class Details extends Component {
constructor(props){
super(props);
this.state = {
question: null,
};
}
componentDidMount(){
const { match: { params } } = this.props;
axios.get(params.uri).then((res)=>{
const question = res.data[0]['uri'];
axios.get(question).then((qRes) => {
console.log(qRes); //will return the data from the second uri
})
console.log(question);
this.setState({ question });
})
}
This is JSON data where Object URI contains a JSON File So I want to fetch data from URI JSON file. 这是JSON数据,其中对象URI包含一个JSON文件,因此我想从URI JSON文件中获取数据。
[
{
"id": 59413,
"thumbnail": {
"id": "60255",
"title": "dornoch-castle-whisky-bar",
"alt": "dornoch-castle-whisky-bar",
"url": "https://media-magazine.trivago.com/wp-content/uploads/2019/01/23144800/dornoch-castle-whisky-bar.jpg",
"courtesy": "",
"position": "center"
},
"thumbnail_url": "https://media-magazine.trivago.com/wp-content/uploads/2019/01/23144800/dornoch-castle-whisky-bar.jpg",
"slug": "dornoch-castle-scotland-whisky",
"uri": "http://trivago-magazine-work-sample-server.s3-website.eu-central-1.amazonaws.com/dornoch-castle-scotland-whisky.json",
"title": "Dornoch Castle: A Whisky Tasting at One of the World's Most Popular Hotel Bars",
"card_title": "Whisky Tasting at Dornoch Castle in the Scottish Highlands",
"show_publish_date": false,
"date": "January 29th, 2019",
"newsletter_popup": false,
"newsletter_popup_header_image": false,
"taxonomies": {
"destinations": [
{
"name": "Europe",
"uri": "/destination/international/europe",
"slug": "europe",
"term_id": 1384
}
],
"themes": [],
"types": [
{
"name": "Nature",
"uri": "/type/nature",
"slug": "nature",
"term_id": 1380
}
]
},
"excerpt": "Dornoch Castle has amassed a whisky collection unlike most any other in the world. trivago Magazine Editor, Joe Baur, signs up for their whisky tasting. Video below."
},
And This is console image enter image description here 这是控制台图像,请在此处输入图像描述
You only can load data from a different domain if the response headers from the server, indicating that the resource is allowed to be accessed by other websites directly. 如果服务器的响应标头表明您允许其他网站直接访问该资源,则只能从其他域加载数据。 Otherwise, you may create a proxy on your server to download the data. 否则,您可以在服务器上创建代理以下载数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.