Skip to content

Commit 4e25f2b

Browse files
authored
Create promises.ts
1 parent d8aa8bb commit 4e25f2b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

promises.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function fetchData(url: string): Promise<string> {
2+
return fetch(url)
3+
.then(response => response.text())
4+
.then(text => {
5+
console.log(`Data fetched: ${text}`);
6+
return text;
7+
});
8+
}
9+
10+
fetchData("https://example.com")
11+
.then(data => console.log(`Data received: ${data}`));

0 commit comments

Comments
 (0)