Avatar

jte

5 public vals
Joined January 30, 2023
1
export export let test = () => {};
1
2
3
4
export export let parseHtml = (content: string) => {
const parser = new DOMParser();
return parser.parseFromString(content);
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { fetch } from "https://esm.town/v/std/fetch";
export let fetchText = async (url: string, options?: any) => {
let f = await fetch(url, {
...options,
headers: {
...(options?.headers || {}),
},
});
let t = await f.text();
try {
return t;
} catch (e) {
throw new e.constructor(`${e.message} in ${url}\n\n"${t}"`);
}
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { fetch } from "https://esm.town/v/std/fetch";
export let hnSearch = async () => {
let url =
"http://www.ausonvert.com/product-category/clavier-et-piano/pianos-numeriques/";
await fetch(url)
.then((response) => {
if (response.ok) {
let text = await response.text();
console.log("Réponse OK");
console.log(text);
} else {
console.log("Mauvaise réponse du réseau");
}
})
.catch((error) => {
console.log(
"Il y a eu un problème avec l'opération fetch : " + error.message
);
});
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { fetch } from "https://esm.town/v/std/fetch";
export let svSearch = async (params) => {
let url =
"http://www.ausonvert.com/product-category/clavier-et-piano/pianos-numeriques/";
fetch(url)
.then((response) => {
if (response.ok) {
console.log("test");
} else {
console.log("Mauvaise réponse du réseau");
}
})
.catch((error) => {
console.log(
"Il y a eu un problème avec l'opération fetch : " + error.message
);
});
};
Next