From edbe8ba10030c41d0225ca5feb944f26ea164474 Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:13:56 +0100 Subject: [PATCH 1/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e084f0d0db..bd3ce2d598 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,5 @@ This is the simplest possible nodejs api using the base http library that responds to any request with: ``` -Yo! +Yo BRUH! ``` From fef72ad22048112d992302981fc29734b955e453 Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:44:56 +0100 Subject: [PATCH 2/8] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5f35242ee8..30b9f0d6fd 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ var http = require('http'); http.createServer(function (req, res) { console.log(`Just got a request at ${req.url}!`) - res.write('Yo!'); + res.write('Yo BRUH!'); res.end(); -}).listen(process.env.PORT || 3000); \ No newline at end of file +}).listen(process.env.PORT || 3000); From 8afde62aebb4d0f184a048a28a7bc9513cf637e5 Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:50:44 +0100 Subject: [PATCH 3/8] Update index.js --- index.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 30b9f0d6fd..2a8c1c2bb9 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,16 @@ -var http = require('http'); -http.createServer(function (req, res) { - console.log(`Just got a request at ${req.url}!`) - res.write('Yo BRUH!'); - res.end(); -}).listen(process.env.PORT || 3000); + + +const https = require("https"); +const url = "https://jsonplaceholder.typicode.com/posts/1"; + +https.get(url, res => { + res.setEncoding("utf8"); + let body = ""; + res.on("data", data => { + body += data; + }); + res.on("end", () => { + body = JSON.parse(body); + console.log(body); + }); +}); From 8a1c181a4805dd00f851c9ab7f74e9774812bcb0 Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:08:31 +0100 Subject: [PATCH 4/8] Update index.js --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 2a8c1c2bb9..ed2258b38c 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,10 @@ +var http = require('http'); +http.createServer(function (req, res) { + console.log(`Just got a request at ${req.url}!`) + + + const https = require("https"); const url = "https://jsonplaceholder.typicode.com/posts/1"; @@ -14,3 +20,5 @@ https.get(url, res => { console.log(body); }); }); + + }).listen(process.env.PORT || 3000); From 3a2b1bb573c4bbe3d2246aa07c1cbdb5f2961b74 Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:17:25 +0100 Subject: [PATCH 5/8] Update index.js --- index.js | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index ed2258b38c..cda5818821 100644 --- a/index.js +++ b/index.js @@ -1,24 +1,11 @@ var http = require('http'); http.createServer(function (req, res) { + const url = "https://jsonplaceholder.typicode.com/posts/1"; console.log(`Just got a request at ${req.url}!`) - - - - -const https = require("https"); -const url = "https://jsonplaceholder.typicode.com/posts/1"; - -https.get(url, res => { - res.setEncoding("utf8"); - let body = ""; - res.on("data", data => { - body += data; - }); - res.on("end", () => { - body = JSON.parse(body); - console.log(body); - }); -}); - - }).listen(process.env.PORT || 3000); +fetch('https://jsonplaceholder.typicode.com/todos/1') + .then(response => response.json()) + .then(json => res.write(json)) + + res.end(); +}).listen(process.env.PORT || 3000); From b093b856c81f8b0330653da2a2940559831cf24a Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:20:16 +0100 Subject: [PATCH 6/8] Update index.js --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index cda5818821..598cf43549 100644 --- a/index.js +++ b/index.js @@ -3,9 +3,7 @@ var http = require('http'); http.createServer(function (req, res) { const url = "https://jsonplaceholder.typicode.com/posts/1"; console.log(`Just got a request at ${req.url}!`) -fetch('https://jsonplaceholder.typicode.com/todos/1') - .then(response => response.json()) - .then(json => res.write(json)) - + + res.write(req.url) res.end(); }).listen(process.env.PORT || 3000); From 1702c52d0a29b1f01433e4153632332c11990bb3 Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:38:13 +0100 Subject: [PATCH 7/8] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 598cf43549..0b398e98c0 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,6 @@ http.createServer(function (req, res) { const url = "https://jsonplaceholder.typicode.com/posts/1"; console.log(`Just got a request at ${req.url}!`) - res.write(req.url) + res.write(req.url.json()) res.end(); }).listen(process.env.PORT || 3000); From 8be5f5c571d6038fd91485108bc5f2cdd4a059de Mon Sep 17 00:00:00 2001 From: tojestzwyklytest <117093995+tojestzwyklytest@users.noreply.github.com> Date: Mon, 31 Oct 2022 16:51:21 +0100 Subject: [PATCH 8/8] Update index.js --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0b398e98c0..d9c7dd8dbe 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ var http = require('http'); http.createServer(function (req, res) { - const url = "https://jsonplaceholder.typicode.com/posts/1"; + // const url = "https://jsonplaceholder.typicode.com/posts/1"; console.log(`Just got a request at ${req.url}!`) - res.write(req.url.json()) + res.write("yo") res.end(); }).listen(process.env.PORT || 3000);