better formatting

This commit is contained in:
AAA1exa8 2021-05-20 16:19:43 +02:00
parent 0d48ca6a1f
commit 7e2d9eb658
2 changed files with 17 additions and 11 deletions

View file

@ -1,15 +1,9 @@
<script>
var name = "overlord";
const base = "https://api.mangadex.org/";
function request(endpoint, query, type = "GET", body) {
return fetch(base + endpoint + "?" + query, {
method: type,
body: body ? JSON.stringify(body) : undefined
}).then(resp => resp.json());
}
import request from "./request";
var name = "";
var result = request("manga", "title=" + name + "&contentRating[]=safe&contentRating[]=suggestive");
$: result = request("manga", "title=" + name + "&contentRating[]=safe&contentRating[]=suggestive");
result.then(console.log);
</script>
@ -38,8 +32,10 @@
<style>
main
{
max-width: 720px;
max-width: 450px;
margin: auto;
}
input {
width: 100%;
}
</style>

10
src/request.js Normal file
View file

@ -0,0 +1,10 @@
const base = "https://api.mangadex.org/";
function request(endpoint, query, type = "GET", body) {
return fetch(base + endpoint + "?" + query, {
method: type,
body: body ? JSON.stringify(body) : undefined
}).then(resp => resp.json());
}
export default request;