0

I am trying to send status 404 but I am not able to send it while using the following code. I am using version 5 for react-router-dom. I have tried various ways but its still not showing the correct status and shows 200 for every URL.

  return (
    <Router>
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to the Pokédex</h1>
        </header>
        <br />
        <br />
        <div className="App-body">
          <h2>Information about Pokémon, Berries and Machine</h2>
          <p>This website will tell you about how pokemon works.</p>
          <Link className="showlink" to="/pokemon/page/0">
            Pokémon
          </Link>
          <Link className="showlink" to="/berries/page/0">
            Berries
          </Link>
          <Link className="showlink" to="/machines/page/0">
            Machines
          </Link>
          <Switch>
            <Route exact path="/" />
            <Route
              exact
              path="/pokemon/page/:page"
              exact
              component={PokemonList}
            />
            <Route
              exact
              path="/berries/page/:page"
              exact
              component={BerriesList}
            />
            <Route
              exact
              path="/machines/page/:page"
              exact
              component={MachineList}
            />
            <Route exact path="/pokemon/:id" exact component={Pokemon} />
            <Route exact path="/berries/:id" exact component={Berries} />
            <Route exact path="/machines/:id" exact component={Machines} />
            <Route path="*" status={404}>
              <PageNotFound />
            </Route>
          </Switch>
        </div>
      </div>
    </Router>
  );
}
2
  • This may help you stackoverflow.com/q/36052604 Commented Apr 6, 2020 at 19:19
  • Not that helpful. I have tried all of that @SarthakAggarwal Commented Apr 6, 2020 at 19:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.