小编Lex*_*Lex的帖子

在 GatsbyJS 上获取 URL 参数

有没有办法检索在 GatsbyJS 上构建的项目页面上传递的 url 参数?我正在尝试使用 AWS 在我的页面上实现密码重置功能,但他们只能通过发送到用户电子邮件的链接发送参数。

所以流程是这样的:

用户触发忘记密码 -> AWS 通过链接向用户发送电子邮件 -> 链接使用参数定向到我的页面 -> 重置密码表单自动使用传递的参数填充字段

更新

这是我的 App.js 代码:

import { Router } from "@reach/router"


const App = () => (
  <Layout>
    <Router>
      <Login path="signin" exact component={Login} />
      <Resources path="api/resources" exact component={Resources} />
      <Verify path="verify" exact component={Verify} />
      <Forgot path="forgot" exact component={Forgot} />
      <Reset path="account/reset/:code" exact component={Reset}/>
    </Router>
  </Layout>
)

export default App;
Run Code Online (Sandbox Code Playgroud)

重置.js:

export default class ResetForm extends Component {
    constructor(props) {
        super(props);

        this.state = {
            password: "", …
Run Code Online (Sandbox Code Playgroud)

javascript amplifyjs amazon-cognito gatsby aws-amplify

11
推荐指数
2
解决办法
2万
查看次数