I would like to base an input search.
To be able to send the content to another page which then makes an API request with the content of the input search.
Basically I would like the user to be able with the search bar, type "something" and that this "something" I get it to make an API request with.
My file :
- index.js
- search
- q.js
index.js :
...
form action="./search/q" method="get">
<button type="submit">
<i class="fas fa-search fa-2x"></i>
</button>
<input type="text" placeholder="Search" id="query" name="serach" />
</form>
q.js :
import Head from "next/head";
export default function Home({ articles }) {
return (
<>
<Head>
<title>Test</title>
</Head>
<main class="container">...</main>
</>
);
}
export async function getStaticProps() {
const articles = await fetch(`...${query}`).then((r) => r.json());
return {
props: {
articles,
},
};
}