forked from bleedingcode/node-red-weather-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode-red-flows-final.json
642 lines (642 loc) · 23.1 KB
/
node-red-flows-final.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
[
{
"id": "5f945dce.37c694",
"type": "tab",
"label": "Weather Dashboard",
"disabled": false,
"info": ""
},
{
"id": "f6de9468.a6a8c8",
"type": "http in",
"z": "5f945dce.37c694",
"name": "Weather Dashboard",
"url": "/weather/dashboard",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 190,
"y": 200,
"wires": [
[
"7cfd6eb3.76f3c"
]
]
},
{
"id": "392b9b74.012bc4",
"type": "http response",
"z": "5f945dce.37c694",
"name": "",
"statusCode": "",
"headers": {},
"x": 630,
"y": 720,
"wires": []
},
{
"id": "98315ebb.fd11c",
"type": "http request",
"z": "5f945dce.37c694",
"name": "Fetch OWM",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 370,
"y": 300,
"wires": [
[
"bc2ea072.f271d"
]
]
},
{
"id": "6039e25a.497fac",
"type": "template",
"z": "5f945dce.37c694",
"name": "Build HTML Page",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width\">\n <title>Weather Dashboard</title>\n <link href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css\" rel=\"stylesheet\" type=\"text/css\" />\n <style>\n .section {\n top: 0;\n width: 100%;\n z-index: 999;\n background-color: #111111;\n color: #ccc;\n border-top: solid 3px #1E97E3;\n height: 50px;\n }\n\n\n .menuitem {\n margin-top: 12px;\n display: inline-block;\n width: 100px;\n }\n\n .menulink {\n height: 40px;\n padding: 7px;\n border-bottom: 3px solid transparent;\n }\n\n .menulink:hover {\n border-bottom: 3px solid #1E97E3;\n text-decoration: none;\n color: #1E97E3;\n }\n\n .footer {\n margin-top: 12px;\n }\n\n .liitem {\n height: 45px;\n }\n\n .skillLine {\n display: inline-block;\n width: 100%;\n min-height: 90px;\n padding: 3px 4px;\n }\n\n skillLineDefault {\n padding: 3px 4px;\n }\n\n div.skill {\n background: #F58723;\n border-radius: 3px;\n color: white;\n font-weight: bold;\n padding: 3px 4px;\n width: 70px;\n }\n\n .rating {\n margin-left: 30px;\n }\n\n .footerQR {\n margin-left: 30%;\n }\n\n .leftText {\n font-size: 41px;\n }\n\n .rightText {\n font-size: 41px;\n background: #F58723;\n border-radius: 3px;\n color: white;\n padding: 3px 4px;\n }\n </style>\n</head>\n\n<body>\n <div class=\"container\">\n <div class=\"row\" style=\"margin-top: 30px\">\n <div class=\"col-xs-10 col-sm-8 col-sm-offset-2 col-xs-offset-1\">\n <form id=\"searchForm\">\n <div class=\"form-group\">\n <div class=\"input-group\">\n <input id=\"inputSearch\" type=\"text\" class=\"form-control input-lg\" name=\"search\"\n placeholder=\"Search 'city name' or 'city, country code' \" />\n <span class=\"input-group-btn\">\"\n <button id=\"searchSubmit\" type=\"submit\" class=\"btn btn-primary btn-lg ladda-button\"\n data-style=\"expand-right\" type=\"submit\"><span class=\"ladda-label\">Search</span></button>\n </span>\n </div>\n </div>\n </form>\n </div>\n </div>\n <h2 style=\"text-align: center;margin: auto\">{{payload.header}}</h2>\n {{#req.query.search}}\n <div class=\"container\">\n <br />\n <div class=\"row\">\n <div class=\"col-sm-6 col-lg-4\">\n <div class=\"panel panel-primary\" style=\"height: 450px;\">\n <div class=\"panel-heading\">\n <h4 class=\"text-center\">Current Forecast<span class=\"glyphicon glyphicon-asterisk pull-right\"></span>\n </h4>\n </div>\n <div class=\"panel-body text-center\">\n <p>\n <strong>{{payload.current.description}}</strong>\n <img src=\"https://openweathermap.org/img/wn/{{payload.current.icon}}@2x.png\" />\n </p>\n </div>\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item liitem\"><strong>Temperature:</strong>\n <span class=\"pull-right\">{{payload.current.temperature}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Feels Like:</strong>\n <span class=\"pull-right\">{{payload.current.feelsLike}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Humidity:</strong>\n <span class=\"pull-right\">{{payload.current.humidity}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Sunrise:</strong>\n <span class=\"pull-right\">{{payload.current.sunrise}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Sunset:</strong>\n <span class=\"pull-right\">{{payload.current.sunset}}</span>\n </li>\n </ul>\n </div>\n </div>\n <div class=\"col-sm-6 col-lg-4\">\n <div class=\"panel panel-primary\" style=\"height: 450px;\">\n <div class=\"panel-heading\">\n <h4 class=\"text-center\">5 Day Weather Forecast<span\n class=\"glyphicon glyphicon-list pull-right\"></span></h4>\n </div>\n <table class=\"table table-hover\">\n {{#payload.fiveDay}}\n <tr>\n <td>{{date}}</td>\n <td>{{temperature}} - {{description}}</td>\n <td><img style=\"margin-top: -10px;\" src=\"https://openweathermap.org/img/wn/{{icon}}.png\" /></td>\n </tr>\n {{/payload.fiveDay}}\n </table>\n </div>\n </div>\n <div class=\"col-sm-6 col-lg-4\">\n <div class=\"panel panel-primary\" style=\"height: 450px;\">\n <div class=\"panel-heading\">\n <h4 class=\"text-center\">About {{payload.country.name}}<span class=\"glyphicon glyphicon-map-marker pull-right\"></span></h4>\n </div>\n <div class=\"panel-body text-center\">\n <img src=\"{{payload.country.flagUrl}}\" width=\"20%\" />\n </div>\n <ul class=\"list-group list-group-flush\">\n <li class=\"list-group-item liitem\"><strong>Code:</strong>\n <span class=\"pull-right\">{{payload.country.code}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Capital:</strong>\n <span class=\"pull-right\">{{payload.country.capital}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Population:</strong>\n <span class=\"pull-right\">{{payload.country.population}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Currencies:</strong>\n <span class=\"pull-right\">{{payload.country.currencies}}</span>\n </li>\n <li class=\"list-group-item liitem\"><strong>Languages:</strong>\n <span class=\"pull-right\">{{payload.country.languages}}</span>\n </li>\n </ul>\n </div>\n </div>\n </div>\n </div>\n {{/req.query.search}}\n </div>\n <script src=\"https://code.jquery.com/jquery.min.js\"></script>\n <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js\"></script>\n <script type=\"text/javascript\">\n $(document).ready(function (e) {\n $(\"#searchSubmit\").click(function (e) {\n e.preventDefault()\n var search = $('#inputSearch').val()\n var url = location.protocol + \"//\" + location.host + location.pathname\n if (!search) return alert(\"Please provide a search term\");\n url += '?search=' + search;\n window.location.replace(url);\n });\n });\n </script>\n</body>\n\n</html>",
"output": "str",
"x": 450,
"y": 740,
"wires": [
[
"392b9b74.012bc4"
]
]
},
{
"id": "ea92cefc.e69cb",
"type": "switch",
"z": "5f945dce.37c694",
"name": "Check Search Query",
"property": "req.query.search",
"propertyType": "msg",
"rules": [
{
"t": "nempty"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 640,
"y": 200,
"wires": [
[
"7ac8de74.7d946"
],
[
"6e101437.735f6c"
]
]
},
{
"id": "b95e0cc5.6e17e",
"type": "inject",
"z": "5f945dce.37c694",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"x": 170,
"y": 80,
"wires": [
[
"6b7dc945.386558"
]
]
},
{
"id": "6b7dc945.386558",
"type": "change",
"z": "5f945dce.37c694",
"name": "Set Params",
"rules": [
{
"t": "set",
"p": "owmAppId",
"pt": "flow",
"to": "c2d91713abf1773c9fb94c886350f03a",
"tot": "str"
},
{
"t": "set",
"p": "owmUnits",
"pt": "flow",
"to": "metric",
"tot": "str"
},
{
"t": "set",
"p": "owmTemperatureUnit",
"pt": "flow",
"to": "°C",
"tot": "str"
},
{
"t": "set",
"p": "owmUrlCurrentForecast",
"pt": "flow",
"to": "https://api.openweathermap.org/data/2.5/weather",
"tot": "str"
},
{
"t": "set",
"p": "owmUrl5DayForecast",
"pt": "flow",
"to": "https://api.openweathermap.org/data/2.5/forecast/daily",
"tot": "str"
},
{
"t": "set",
"p": "restCountryUrl",
"pt": "flow",
"to": "https://restcountries.eu/rest/v2/alpha/",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 320,
"y": 80,
"wires": [
[]
]
},
{
"id": "ea4b785b.71dbf8",
"type": "function",
"z": "5f945dce.37c694",
"name": "Prep",
"func": "msg.url = flow.get('owmUrlCurrentForecast')\nmsg.url += `?appid=${flow.get('owmAppId')}`\nmsg.url += `&units=${flow.get('owmUnits')}`\nmsg.url += `&q=${msg.req.query.search}`\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 210,
"y": 300,
"wires": [
[
"98315ebb.fd11c"
]
]
},
{
"id": "f4cd3344.ea2eb",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Set Memory Variables",
"info": "",
"x": 180,
"y": 40,
"wires": []
},
{
"id": "3fed2f38.226e4",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Weather Dashboard Flow",
"info": "",
"x": 190,
"y": 160,
"wires": []
},
{
"id": "606c169f.330f58",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Fetch Current Weather Forecast",
"info": "",
"x": 230,
"y": 260,
"wires": []
},
{
"id": "b57620d9.c543",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Finalize",
"info": "",
"x": 130,
"y": 680,
"wires": []
},
{
"id": "3db76719.0a4a18",
"type": "link in",
"z": "5f945dce.37c694",
"name": "Finalize",
"links": [
"6e101437.735f6c",
"833912d3.dd698",
"e1dbc8b5.ae8b48",
"b9ae2edd.d5348"
],
"x": 95,
"y": 720,
"wires": [
[
"8597c38b.d0cd6"
]
]
},
{
"id": "ec81deea.eeef2",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Error Handling",
"info": "",
"x": 150,
"y": 580,
"wires": []
},
{
"id": "b41ed870.93cb08",
"type": "catch",
"z": "5f945dce.37c694",
"name": "",
"scope": null,
"uncaught": false,
"x": 150,
"y": 620,
"wires": [
[
"d67d71a4.66aa1"
]
]
},
{
"id": "5883567b.b07608",
"type": "link in",
"z": "5f945dce.37c694",
"name": "Fetch Current Forecast",
"links": [
"7ac8de74.7d946"
],
"x": 115,
"y": 300,
"wires": [
[
"ea4b785b.71dbf8"
]
]
},
{
"id": "7ac8de74.7d946",
"type": "link out",
"z": "5f945dce.37c694",
"name": "Run Fetch Current Forecast",
"links": [
"5883567b.b07608"
],
"x": 775,
"y": 180,
"wires": []
},
{
"id": "6e101437.735f6c",
"type": "link out",
"z": "5f945dce.37c694",
"name": "Run Finalize",
"links": [
"3db76719.0a4a18"
],
"x": 775,
"y": 220,
"wires": []
},
{
"id": "833912d3.dd698",
"type": "link out",
"z": "5f945dce.37c694",
"name": "Run Finalize",
"links": [
"3db76719.0a4a18"
],
"x": 415,
"y": 620,
"wires": []
},
{
"id": "e50a1f81.e62a2",
"type": "link out",
"z": "5f945dce.37c694",
"name": "Run Fetch 5 Day Forecast",
"links": [
"b09d1f1a.11d88"
],
"x": 695,
"y": 300,
"wires": []
},
{
"id": "d67d71a4.66aa1",
"type": "function",
"z": "5f945dce.37c694",
"name": "",
"func": "msg.payload.header = `${msg.error.message} - \"${msg.req.query.search}\"`\ndelete msg.req.query.search\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 620,
"wires": [
[
"833912d3.dd698"
]
]
},
{
"id": "bc2ea072.f271d",
"type": "function",
"z": "5f945dce.37c694",
"name": "Process Result",
"func": "let errMsg = null\n\n// First check response for error\nif (msg.statusCode >= 400) {\n try {\n errMsg = msg.payload.message\n } catch (e) {\n errMsg = msg.payload\n }\n \n throw new Error(errMsg)\n}\n\n// Process response data\nmsg.countryCode = msg.payload.sys.country\nmsg.result.header = msg.payload.name\n\nlet tmpSunrise = msg.payload.sys.sunrise * 1000\ntmpSunrise = new Date(tmpSunrise)\nlet sunrise = tmpSunrise.toLocaleTimeString([], { hour: '2-digit', minute: \"2-digit\", hour12: true })\n\nlet tmpSunset = msg.payload.sys.sunset * 1000\ntmpSunset = new Date(tmpSunset)\nlet sunset = tmpSunset.toLocaleTimeString([], { hour: '2-digit', minute: \"2-digit\", hour12: true })\n\nmsg.result.current = {\n description: msg.payload.weather[0].description,\n icon: msg.payload.weather[0].icon,\n temperature: `${Math.round(msg.payload.main.temp)}${flow.get('owmTemperatureUnit')}`,\n feelsLike: `${Math.round(msg.payload.main.feels_like)}${flow.get('owmTemperatureUnit')}`,\n humidity: `${msg.payload.main.humidity}%`,\n sunrise,\n sunset\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 300,
"wires": [
[
"e50a1f81.e62a2"
]
]
},
{
"id": "7cfd6eb3.76f3c",
"type": "change",
"z": "5f945dce.37c694",
"name": "Prep Variables",
"rules": [
{
"t": "set",
"p": "result",
"pt": "msg",
"to": "{}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 200,
"wires": [
[
"ea92cefc.e69cb"
]
]
},
{
"id": "ce3dc5c3.efd6a8",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Fetch 5 Day Forecast",
"info": "",
"x": 200,
"y": 360,
"wires": []
},
{
"id": "b30e5de4.c31ab",
"type": "http request",
"z": "5f945dce.37c694",
"name": "Fetch OWM",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 370,
"y": 400,
"wires": [
[
"13a14bac.af2f64"
]
]
},
{
"id": "8f726635.4a3118",
"type": "function",
"z": "5f945dce.37c694",
"name": "Prep",
"func": "msg.url = flow.get('owmUrl5DayForecast')\nmsg.url += `?appid=${flow.get('owmAppId')}`\nmsg.url += `&units=${flow.get('owmUnits')}`\nmsg.url += `&q=${msg.req.query.search}`\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 210,
"y": 400,
"wires": [
[
"b30e5de4.c31ab"
]
]
},
{
"id": "b09d1f1a.11d88",
"type": "link in",
"z": "5f945dce.37c694",
"name": "Fetch 5 Day Forecast",
"links": [
"e50a1f81.e62a2"
],
"x": 115,
"y": 400,
"wires": [
[
"8f726635.4a3118"
]
]
},
{
"id": "ef3513a1.c5b59",
"type": "link out",
"z": "5f945dce.37c694",
"name": "Run Fetch Country",
"links": [
"68ba574d.481a58"
],
"x": 695,
"y": 400,
"wires": []
},
{
"id": "13a14bac.af2f64",
"type": "function",
"z": "5f945dce.37c694",
"name": "Process Result",
"func": "let errMsg = null\n\n// First check response for error\nif (msg.statusCode >= 400) {\n try {\n errMsg = msg.payload.message\n } catch (e) {\n errMsg = msg.payload\n }\n \n throw new Error(errMsg)\n}\n\n// Process response data\nmsg.result.fiveDay = []\nlet date\nlet tmpDate = null\nlet tmpEntry\nlet x = 0\nlet y = msg.payload.list.length\n\nfor (;x < y; x++) {\n tmpEntry = msg.payload.list[x]\n tmpDate = tmpEntry.dt * 1000\n tmpDate = new Date(tmpDate)\n date = `${tmpDate.getDate()}/${(tmpDate.getMonth() + 1)}`\n\n msg.result.fiveDay.push({\n date,\n temperature: `${Math.round(tmpEntry.temp.max)}${flow.get('owmTemperatureUnit')}`,\n description: tmpEntry.weather[0].description,\n icon: tmpEntry.weather[0].icon,\n \n })\n \n // We only need 5 entries\n if (x === 4) break\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 400,
"wires": [
[
"ef3513a1.c5b59"
]
]
},
{
"id": "7df06cdc.4c9d64",
"type": "comment",
"z": "5f945dce.37c694",
"name": "Fetch Country Info",
"info": "",
"x": 190,
"y": 460,
"wires": []
},
{
"id": "7131392d.7fb668",
"type": "http request",
"z": "5f945dce.37c694",
"name": "Fetch Country",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 380,
"y": 500,
"wires": [
[
"8d4c02b9.22db1"
]
]
},
{
"id": "bfd36366.648e7",
"type": "function",
"z": "5f945dce.37c694",
"name": "Prep",
"func": "msg.url = `${flow.get('restCountryUrl')}${msg.countryCode}`\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 210,
"y": 500,
"wires": [
[
"7131392d.7fb668"
]
]
},
{
"id": "68ba574d.481a58",
"type": "link in",
"z": "5f945dce.37c694",
"name": "Fetch Country",
"links": [
"ef3513a1.c5b59"
],
"x": 115,
"y": 500,
"wires": [
[
"bfd36366.648e7"
]
]
},
{
"id": "b9ae2edd.d5348",
"type": "link out",
"z": "5f945dce.37c694",
"name": "Run Finalize",
"links": [
"3db76719.0a4a18"
],
"x": 715,
"y": 500,
"wires": []
},
{
"id": "8d4c02b9.22db1",
"type": "function",
"z": "5f945dce.37c694",
"name": "Process Result",
"func": "let errMsg = null\n\n// First check response for error\nif (msg.statusCode >= 400) {\n try {\n errMsg = msg.payload.message\n } catch (e) {\n errMsg = msg.payload\n }\n \n throw new Error(errMsg)\n}\n\n// Process response data\nmsg.result.header += `, ${msg.payload.nativeName}`\n\nlet currencies = []\nlet languages = []\n\nfor (const currency of msg.payload.currencies) {\n currencies.push(`${currency.code} (${currency.symbol})`)\n}\n\nfor (const language of msg.payload.languages) {\n languages.push(language.name)\n}\n\nmsg.result.country = {\n name: msg.payload.nativeName,\n code: msg.payload.alpha2Code,\n capital: msg.payload.capital,\n population: Intl.NumberFormat().format(msg.payload.population),\n currencies: currencies.join(', '),\n languages: languages.join(', '),\n flagUrl: msg.payload.flag\n}\n\nmsg.payload = msg.result\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 500,
"wires": [
[
"b9ae2edd.d5348"
]
]
},
{
"id": "8597c38b.d0cd6",
"type": "switch",
"z": "5f945dce.37c694",
"name": "Check Output Query",
"property": "req.query.output",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "json",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 240,
"y": 720,
"wires": [
[
"392b9b74.012bc4"
],
[
"6039e25a.497fac"
]
]
}
]