Vanilla JS
How to use it JavaScript.
We have this page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ShapeRQ</title>
</head>
<body>
<div id="getData"></div>
<div id="output"></div>
</body>
</html>
And, we need to got some cheese for this page.
What about it?
import { httpGet, createConfig } from "shape-rq";
createConfig({
APIs: { cheese: { baseUrl: "https://cheese-api.onrender.com" } },
lang: "en",
});
document.getElementById("getData").onclick = async () => {
const res = await httpGet("cheese", "/cheeses");
if (!res) return alert("No cheese :(");
document.getElementById("output").textContent = JSON.stringify(res);
};
Last updated