我正在尝试为我的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) 我正在开发一个 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 ×2
node.js ×2
reactjs ×2
chatgpt-api ×1
material-ui ×1
openai-api ×1
react-router ×1