File tree Expand file tree Collapse file tree 12 files changed +3171
-2
lines changed Expand file tree Collapse file tree 12 files changed +3171
-2
lines changed Original file line number Diff line number Diff line change @@ -58,3 +58,4 @@ I am an independent educator and open-source enthusiast who creates meaningful p
58
58
- ** ` Day 22: Asynchronous JavaScript - Callback ` ** - [ Watch Video] ( https://youtu.be/EtoHtZ8mdWA ) || [ Source Code] ( https://github.com/tapascript/40-days-of-javascript/blob/main/day-22/README.md )
59
59
- ** ` Day 23: JavaScript Promises: Zero to Hero ` ** - [ Watch Video] ( https://youtu.be/R52MdtIW3rs ) || [ Source Code] ( https://github.com/tapascript/40-days-of-javascript/blob/main/day-23/README.md )
60
60
- ** ` Day 24: Master JavaScript async/await & Simplify Promises Like a PRO ` ** - [ Watch Video] ( https://youtu.be/WQdCffdPPKI ) || [ Source Code] ( https://github.com/tapascript/40-days-of-javascript/blob/main/day-24/README.md )
61
+ - ** ` Day 25: JavaScript fetch() Explained Like Never Before ` ** - [ Watch Video] ( https://www.youtube.com/watch?v=G3oPZSvrO9w ) || [ Source Code] ( https://github.com/tapascript/40-days-of-javascript/blob/main/day-25/README.md )
Original file line number Diff line number Diff line change
1
+ {
2
+ "posts" : [
3
+ {
4
+ "title" : " What is 40 Days of JavaScript?" ,
5
+ "views" : 160 ,
6
+ "id" : " a9057951-515e-3da2-9793-af29719d0e33"
7
+ },
8
+ {
9
+ "id" : " a9057951-215e-4da2-9793-af29719d0e33" ,
10
+ "title" : " How to Split a String?" ,
11
+ "views" : 201
12
+ },
13
+ {
14
+ "id" : " 4b9d7b5c-4a6d-4149-988e-7536ed90a518" ,
15
+ "title" : " How to use fetch() API for POST?" ,
16
+ "views" : 0
17
+ }
18
+ ],
19
+ "comments" : [
20
+ {
21
+ "id" : " 1" ,
22
+ "text" : " Great Post" ,
23
+ "postId" : " a9057951-515e-3da2-9793-af29719d0e33"
24
+ },
25
+ {
26
+ "id" : " 2" ,
27
+ "text" : " Learned something new" ,
28
+ "postId" : " a9057951-515e-3da2-9793-af29719d0e33"
29
+ }
30
+ ],
31
+ "profile" : {
32
+ "name" : " tapaScript"
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " blog" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " The Blog API Services used in the tutorials" ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "start" : " node server.js"
8
+ },
9
+ "repository" : {
10
+ "type" : " git" ,
11
+ "url" : " git+https://github.com/tapascript/40-days-of-javascript.git"
12
+ },
13
+ "keywords" : [
14
+ " API"
15
+ ],
16
+ "author" : " Tapas Adhikary | tapaScript" ,
17
+ "license" : " MIT" ,
18
+ "bugs" : {
19
+ "url" : " https://github.com/tapascript/40-days-of-javascript/issues"
20
+ },
21
+ "homepage" : " https://github.com/tapascript/40-days-of-javascript#readme" ,
22
+ "dependencies" : {
23
+ "json-server" : " 0.17.3"
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ const jsonServer = require ( "json-server" ) ;
2
+ const fs = require ( "fs" ) ;
3
+ const path = require ( "path" ) ;
4
+
5
+ const server = jsonServer . create ( ) ;
6
+ const router = jsonServer . router ( "db.json" ) ;
7
+ const middlewares = jsonServer . defaults ( ) ;
8
+
9
+ server . use ( middlewares ) ;
10
+ server . use ( jsonServer . bodyParser ) ;
11
+
12
+ server . post ( "/login" , ( req , res ) => {
13
+ console . log ( "Headers:" , req . headers ) ;
14
+ console . log ( "Body:" , req . body ) ;
15
+
16
+ res . json ( {
17
+ message : "LoggedIn successfully!"
18
+ } ) ;
19
+ } ) ;
20
+
21
+ server . use ( router ) ;
22
+
23
+ server . listen ( 3000 , ( ) => {
24
+ console . log ( "✅ JSON Server running at http://localhost:3000" ) ;
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments