Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
601 views
in Technique[技术] by (71.8m points)

react的next.js服务端渲染,请求不到数据是为什么呢

之前的react,现在要用next.js重构一下
请求数据的时候拿不到

  static async getInitialProps({req,props}) {
    var res = await axios.post('https://api.github.com/repos/zeit/next.js');
    console.log(res);
    console.log(res.owner);
    var serverData = res.owner;
    return serverData;

  }

但是请求不到,不知道会不会和我axios里面写的拦截有关系,我是用了md5加密的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

token不对或者请求资源有跨域等问题,try catch试下,应该看得到有报错


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...