Handling GET requests

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€43.98
List Price:  €61.58
You save:  €17.59
£37.45
List Price:  £52.44
You save:  £14.98
CA$68.94
List Price:  CA$96.52
You save:  CA$27.58
A$77.17
List Price:  A$108.05
You save:  A$30.87
S$64.52
List Price:  S$90.34
You save:  S$25.81
HK$387.93
List Price:  HK$543.13
You save:  HK$155.20
CHF 41.16
List Price:  CHF 57.63
You save:  CHF 16.46
NOK kr513.43
List Price:  NOK kr718.85
You save:  NOK kr205.41
DKK kr328.21
List Price:  DKK kr459.52
You save:  DKK kr131.31
NZ$83.43
List Price:  NZ$116.81
You save:  NZ$33.37
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.45
৳6,093.85
List Price:  ৳8,531.88
You save:  ৳2,438.02
₹4,238.91
List Price:  ₹5,934.81
You save:  ₹1,695.90
RM211.98
List Price:  RM296.79
You save:  RM84.81
₦80,338.92
List Price:  ₦112,480.92
You save:  ₦32,142
₨14,092.14
List Price:  ₨19,730.13
You save:  ₨5,637.98
฿1,634.17
List Price:  ฿2,287.97
You save:  ฿653.80
₺1,931.81
List Price:  ₺2,704.69
You save:  ₺772.88
B$286.58
List Price:  B$401.24
You save:  B$114.65
R914.69
List Price:  R1,280.65
You save:  R365.95
Лв86.04
List Price:  Лв120.46
You save:  Лв34.42
₩69,628.94
List Price:  ₩97,486.09
You save:  ₩27,857.14
₪179.30
List Price:  ₪251.04
You save:  ₪71.73
₱2,769.88
List Price:  ₱3,878.05
You save:  ₱1,108.17
¥7,161.24
List Price:  ¥10,026.31
You save:  ¥2,865.07
MX$982.08
List Price:  MX$1,375
You save:  MX$392.91
QR182.01
List Price:  QR254.83
You save:  QR72.82
P680.79
List Price:  P953.17
You save:  P272.37
KSh6,466.20
List Price:  KSh9,053.20
You save:  KSh2,587
E£2,531.34
List Price:  E£3,544.09
You save:  E£1,012.74
ብር6,728.99
List Price:  ብር9,421.13
You save:  ብር2,692.13
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$46,957.60
List Price:  CLP$65,744.40
You save:  CLP$18,786.80
CN¥364.67
List Price:  CN¥510.57
You save:  CN¥145.90
RD$2,951.01
List Price:  RD$4,131.65
You save:  RD$1,180.64
DA6,618.24
List Price:  DA9,266.07
You save:  DA2,647.82
FJ$112.61
List Price:  FJ$157.67
You save:  FJ$45.05
Q385.11
List Price:  Q539.19
You save:  Q154.07
GY$10,461.12
List Price:  GY$14,646.40
You save:  GY$4,185.28
ISK kr6,435.71
List Price:  ISK kr9,010.51
You save:  ISK kr2,574.80
DH463.01
List Price:  DH648.26
You save:  DH185.24
L854.60
List Price:  L1,196.51
You save:  L341.91
ден2,711.17
List Price:  ден3,795.85
You save:  ден1,084.68
MOP$400.55
List Price:  MOP$560.81
You save:  MOP$160.25
N$933.50
List Price:  N$1,306.98
You save:  N$373.47
C$1,845.09
List Price:  C$2,583.28
You save:  C$738.18
रु6,780.01
List Price:  रु9,492.56
You save:  रु2,712.54
S/183.84
List Price:  S/257.39
You save:  S/73.55
K202.87
List Price:  K284.03
You save:  K81.16
SAR187.51
List Price:  SAR262.53
You save:  SAR75.02
ZK1,390.76
List Price:  ZK1,947.17
You save:  ZK556.41
L224.34
List Price:  L314.09
You save:  L89.75
Kč1,096.77
List Price:  Kč1,535.57
You save:  Kč438.79
Ft17,775.48
List Price:  Ft24,887.10
You save:  Ft7,111.61
SEK kr479.18
List Price:  SEK kr670.89
You save:  SEK kr191.71
ARS$59,737.26
List Price:  ARS$83,636.94
You save:  ARS$23,899.68
Bs346.56
List Price:  Bs485.21
You save:  Bs138.65
COP$214,319.02
List Price:  COP$300,063.78
You save:  COP$85,744.75
₡25,326.52
List Price:  ₡35,459.16
You save:  ₡10,132.63
L1,301.19
List Price:  L1,821.77
You save:  L520.58
₲401,593.41
List Price:  ₲562,262.91
You save:  ₲160,669.49
$U2,096.75
List Price:  $U2,935.62
You save:  $U838.87
zł188.07
List Price:  zł263.32
You save:  zł75.24
Already have an account? Log In

Transcript

In the previous lesson, we have seen how to structure get an A post request using an express application, it's time to write our own first request. So let's use what we saw in the previous lesson. So we are going to use the get function, we will use the root URL and we will use the rest response object dot JSON with that whole string. Now we launch our server node do so node index the GS sorry, and we use curl to perform a very simple GET request on the port 5000. As you can see, we have the whole string. Now let's try to reply with a with an object.

So we will going to create static list of articles that I will copy and paste in the constants directory. So we create the articles.js file and sorry and then we are going to paste this list of articles with all the attributes that you can see in the code in the references and we are going to import this list in our index.gs so require constants articles and we are going to create a new get the article send point request response next and we are going to use again rest dot JSON and we will pass the list of articles. Let's see if everything works correctly. So we are going to terminate the previous Note the process and we started again with the new code and we perform a new car requests and it works fine

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.