Currently, I am utilizing the API to retrieve anime information.
To fetch a specific anime, the endpoint is: https://nyaaapi.herokuapp.com/nyaa/anime?query={nameofanime}
I am seeking to input the name of the anime from the user.
Being new to APIs and JSON, my previous attempts using random endpoints were not successful. I attempted some JavaScript code but it was quite off.
const userInput = document.querySelector("#userInput").value;
fetch("https://nyaaapi.herokuapp.com/nyaa/anime?query=${userInput}")
.then((response) => response.json())
.then((quote) => console.log(quote));
<html>
<head>
<title>
anime
</title>
</head>
<body>
<p>
Anime: <input id="userInput" value="{naruto}" />
<br />
<button id="submit">submit</button>
</p>
<script src="index.js"></script>
</body>
</html>
What's currently functioning: The request is successfully being sent to the API and logged!
What's not working at the moment: While the request is being sent and logged, the relevant information is not showing (see image below).
https://i.sstatic.net/8IxkW.png
Edit: The third answer provided has been most helpful for my requirements. Now, I will work on displaying the logged info to the user.