File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
docs/3-web-servers/06-fetch-api Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,11 @@ import express from "express";
2323
2424const app = express ();
2525app .use (express .static (" ./public" ));
26+
2627app .get (" /weather" , (request , response ) => {
2728 response .send (" 晴れ" );
2829});
30+
2931app .listen (3000 );
3032```
3133
@@ -44,6 +46,7 @@ async function fetchWeather() {
4446 const weather = await response .text ();
4547 document .getElementById (" weather" ).textContent = weather;
4648}
49+
4750fetchWeather ();
4851```
4952
@@ -115,12 +118,14 @@ import express from "express";
115118
116119const app = express ();
117120app .use (express .static (" ./public" ));
121+
118122app .get (" /weather" , (request , response ) => {
119123 response .json ({
120124 condition: " 晴れ" ,
121125 temperature: 25 ,
122126 });
123127});
128+
124129app .listen (3000 );
125130```
126131
@@ -138,6 +143,7 @@ async function fetchWeather() {
138143 document .getElementById (" condition" ).textContent = weather .condition ;
139144 document .getElementById (" temperature" ).textContent = weather .temperature ;
140145}
146+
141147fetchWeather ();
142148```
143149
You can’t perform that action at this time.
0 commit comments