I found this post
and tried to make cross domain request with jsonp but failed both on webpack dev server and live server.
Full code
official_ajax.jsx
const UserGist = React.createClass({
getInitialState: function() {
return {
username: '',
login: ''
};
},
componentDidMount: function() {
$.ajax({
url: this.props.serverPath,
dataType: 'jsonp',
cache: false,
success: function(data) {
const title = data[0];
this.setState ({
username:title.title,
login:title.link
});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.serverPath, status, err.toString());
}.bind(this)
});
},
render:function() {
return (
<div>
{this.state.username} and <a href = {this.state.login}>here</a>
</div>
);
}
});
export default UserGist;
index.jsx
import UserGist from './official_ajax.jsx';
class App extends React.Component {
render () {
return (
<div>
<UserGist serverPath = "http://api.flickr.com/services/feeds/groups_pool.gne?id=807213@N20&lang=en-us&format=json&jsoncallback=?" />
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("app"));
Every time i receive response from server that "connection is not secure". Every ideas will be greatly appreciated.