首页 > 解决方案 > reactjs 从发布的数据中捕获响应

问题描述

我在 node.js 中有以下代码

app.get('/callback', function (req, res) {
  oauthClient
    .createToken(req.url)
    .then(function (authResponse) {
      oauth2_token_json = JSON.stringify(authResponse.getJson(), null, 2);
    })
    .catch(function (e) {
      console.error(e);
    });

  res.send('');
});

并传递回调如下

http://localhost:8000/authUri?json[clientId]=ABdfsdfsdcbLxxwU&json[clientSecret]=EiL8Cuasdsdfsdfl&json[environment]=sandbox&json[redirectUri]=http://localhost:8000/callback

上面的代码工作正常,但是我想在 react js 功能组件中实现这个,比如创建一个函数并给出 url,我尝试在组件内部创建一个函数说示例并给出像

“/样本”

但是不工作可以有人请建议如何做到这一点

这就是我所做的

http://localhost:8000/authUri?json[clientId]=ABdfsdfsdcbLxxwU&json[clientSecret]=EiL8Cuasdsdfsdfl&json[environment]=sandbox&json[redirectUri]=http://localhost:3000/sample

useEffect((req,res) => {
    console.log(req);

},[])

我需要捕获第三方发布的数据

请帮忙,我卡在这里谢谢,

标签: javascriptreactjs

解决方案


推荐阅读