小编bab*_*ins的帖子

REACTJS 给出以下错误: TypeError:navigate.push 不是函数

我正在尝试为我的react.js 网站实现一个主页。我的布局很好,我的代码编译没有问题。

但是,当我单击按钮时,我在网站应用程序上收到以下错误:TypeError: navigate.push is not a function在显示的行上 navigate.push("/quiz")

我是新来的,如果有人能帮助我,我将不胜感激!

这是我的代码:

import { Button } from "@material-ui/core";
import { Container } from "@material-ui/core";
import { useNavigate } from "react-router-dom";
import "./Home.css";

const Home = () => {
  const navigate = useNavigate();

  const sendSubmit = () => {
    navigate.push("/quiz");
  };
  return (
    <Container className="content">
      <h1 id="quiz-title">Phishing Quiz</h1>
      <h2 class="question-text">
        Do you think you can beat our phishing quiz?
      </h2>
      <p className="description">
        {" "}
        There are many social engineering attacks …
Run Code Online (Sandbox Code Playgroud)

javascript node.js reactjs react-router material-ui

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

OpenAI ChatGPT (GPT-3.5) API 错误 404:“请求失败,状态代码 404”

我正在开发一个 ChatGPT-App,使用 React 和 Axios 向 OpenAI 的 GPT-3.5 API 发出 API 请求。但是,我在尝试发出请求时遇到 404 错误。我希望有人可以帮助我确定问题并指导我如何解决它。以下是 App.js 和 index.js 代码和错误消息:

前端

应用程序.js

function App() {
  const [messages, setMessages] = useState([]);
  const [input, setInput] = useState("");

  const sendMessage = async () => {
    if (input.trim() === "") return;
  
    const userInput = input; // Store user input in a temporary variable
    setMessages([...messages, { type: "user", text: userInput }]);
    setInput("");
  
    try {
      const response = await axios.post("http://localhost:5000/api/chat", { text: userInput });
      const gptResponse = …
Run Code Online (Sandbox Code Playgroud)

javascript node.js reactjs openai-api chatgpt-api

2
推荐指数
1
解决办法
6630
查看次数