Skip to content

Commit 6bb5a49

Browse files
committed
port: HTTP Request
1 parent 28cb1e8 commit 6bb5a49

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/HTTP Request/main.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import GLib from "gi://GLib";
22
import Gio from "gi://Gio";
3+
import Gtk from "gi://Gtk?version=4.0";
34
import Soup from "gi://Soup";
45

56
Gio._promisify(
@@ -9,8 +10,10 @@ Gio._promisify(
910
);
1011

1112
const http_session = new Soup.Session();
12-
const article_text_view = workbench.builder.get_object("article_text_view");
13-
const article_title = workbench.builder.get_object("article_title");
13+
const article_text_view = workbench.builder.get_object<Gtk.TextView>(
14+
"article_text_view",
15+
);
16+
const article_title = workbench.builder.get_object<Gtk.Label>("article_title");
1417

1518
fetchWikipediaTodaysFeaturedArticle().catch(console.error);
1619

@@ -25,11 +28,12 @@ async function fetchWikipediaTodaysFeaturedArticle() {
2528
)}`;
2629
const message = Soup.Message.new("GET", url);
2730

31+
// @ts-expect-error undetected async function
2832
const bytes = await http_session.send_and_read_async(
2933
message,
3034
GLib.PRIORITY_DEFAULT,
3135
null,
32-
);
36+
) as GLib.Bytes
3337

3438
if (message.get_status() !== Soup.Status.OK) {
3539
console.error(`HTTP Status ${message.get_status()}`);

0 commit comments

Comments
 (0)