The rendered input is getting interpreted as word 'object' rather than text getting entered in input in React. So I have this API I want to search with input while I am searching it is getting written word 'object' rather than what am I writing.
Object is getting written instead of what I searched for
Here I searched for input but again object is getting written in query
import { useState } from "react";
function () {
const [endpoint, setEndpoint] = useState("");
function searchChange(e) {
setEndpoint(e.target.value);
console.log(endpoint);
const options = {
method: "GET",
headers: {
"X-RapidAPI-Key": "baef7285e6msh0aae02b3fd1dde5p1d01aajsne4c06de3d63f",
"X-RapidAPI-Host": "spotify81.p.rapidapi.com",
},
};
fetch(
"https://spotify81.p.rapidapi.com/search?q=" +
{endpoint} +
"&type=albums&offset=0&limit=10&numberOfTopResults=5",
options
)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));
}
return (
<input
className="input"
value={endpoint}
placeholder=" Search"
onChange={searchChange}
/>
);
}