私はAPIを呼び出して、この情報をレンダリングするために、たSuperAgentを使用していますが、私は間違った方法でそれをやっているデータスーパーエージェントを使用してAPIを呼び出しますか?
{
"data": {
"id": ,
"title": ,
"description": ,
"old_price": "100",
"new_price": "50",
"size": "50",
"quantity": 20,
},
"errors": null,
"code": 1
}
のこのブランチで構成APIを持っています。
ここに私のコード
import React from 'react';
import {render} from 'react-dom';
import superagent from 'superagent';
import Layout from './components/Layout';
class App extends React.Component{
constructor(){
super()
this.state={
name:''
}
}
componentDidMount(){
console.log('componentDidMount');
const url='http://...';
superagent
.get(url)
.query(null)
.set('Accept', 'application/json')
.end ((error, response)=>{
const title=response.body.response
console.log(JSON.stringify(title));
this.setState({
name:title
})
})
}
render(){
return(
<Layout data={this.state}/>
)
}
}
render(<App />, document.getElementById('app'));
ここで私はそれ
しかし、レンダリングされていないレンダリング、私は私が間違っワットでやっていると思いますay。あなたはそれで私を助けてくれますか?私にとって
ねえ、それが働いたのuに感謝
であるべきもちろん、いくつか調整を加えましたが、これが出発点でした) – Feruza