首页 > reactjs有没有推荐的jsonp的实践方式

reactjs有没有推荐的jsonp的实践方式

根据redux官方文档里面的描述,是用fetch()来做ajax的

function fetchPosts(subreddit) {
  return dispatch => {
    dispatch(requestPosts(subreddit))
    return fetch(`http://www.reddit.com/r/${subreddit}.json`)
      .then(response => response.json())
      .then(json => dispatch(receivePosts(subreddit, json)))
  }
}

但问题是没有在fetch的文档里面找到jsonp的实践方式,请问各位都是怎么处理reactjs中的跨域请求的?以前做angular的时候,我是用$http.jsonp()来搞定,现在react里面有没有什么比较推荐的方法呢。

谢谢了!


https://github.com/camsong/fetch-jsonp

不过貌似和reactjs毛线关系都没有,fetch也是

【热门文章】
【热门文章】