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
€44.04
List Price:  €61.67
You save:  €17.62
£37.03
List Price:  £51.85
You save:  £14.81
CA$69.03
List Price:  CA$96.65
You save:  CA$27.62
A$77.35
List Price:  A$108.30
You save:  A$30.94
S$64.30
List Price:  S$90.02
You save:  S$25.72
HK$391.48
List Price:  HK$548.10
You save:  HK$156.62
CHF 41.31
List Price:  CHF 57.84
You save:  CHF 16.52
NOK kr505.53
List Price:  NOK kr707.78
You save:  NOK kr202.25
DKK kr328.58
List Price:  DKK kr460.04
You save:  DKK kr131.45
NZ$83.92
List Price:  NZ$117.50
You save:  NZ$33.57
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳6,086.26
List Price:  ৳8,521.26
You save:  ৳2,434.99
₹4,264.16
List Price:  ₹5,970.17
You save:  ₹1,706
RM211.50
List Price:  RM296.12
You save:  RM84.62
₦79,530.59
List Price:  ₦111,349.19
You save:  ₦31,818.60
₨14,090.87
List Price:  ₨19,728.35
You save:  ₨5,637.47
฿1,631.08
List Price:  ฿2,283.65
You save:  ฿652.56
₺1,951.12
List Price:  ₺2,731.72
You save:  ₺780.60
B$287.34
List Price:  B$402.30
You save:  B$114.96
R894.49
List Price:  R1,252.36
You save:  R357.86
Лв86.19
List Price:  Лв120.67
You save:  Лв34.48
₩68,478.05
List Price:  ₩95,874.75
You save:  ₩27,396.70
₪179.84
List Price:  ₪251.79
You save:  ₪71.95
₱2,765.57
List Price:  ₱3,872.02
You save:  ₱1,106.44
¥7,167.01
List Price:  ¥10,034.39
You save:  ¥2,867.38
MX$963.17
List Price:  MX$1,348.51
You save:  MX$385.34
QR182.63
List Price:  QR255.70
You save:  QR73.06
P674.33
List Price:  P944.12
You save:  P269.78
KSh6,461.20
List Price:  KSh9,046.20
You save:  KSh2,585
E£2,494.51
List Price:  E£3,492.51
You save:  E£998
ብር6,770.25
List Price:  ብር9,478.90
You save:  ብር2,708.64
Kz45,588.63
List Price:  Kz63,827.73
You save:  Kz18,239.10
CLP$47,138.07
List Price:  CLP$65,997.07
You save:  CLP$18,859
CN¥359.12
List Price:  CN¥502.80
You save:  CN¥143.68
RD$2,949.16
List Price:  RD$4,129.06
You save:  RD$1,179.90
DA6,618.79
List Price:  DA9,266.84
You save:  DA2,648.04
FJ$112.87
List Price:  FJ$158.03
You save:  FJ$45.15
Q383.56
List Price:  Q537.02
You save:  Q153.45
GY$10,454.27
List Price:  GY$14,636.81
You save:  GY$4,182.54
ISK kr6,387.22
List Price:  ISK kr8,942.62
You save:  ISK kr2,555.40
DH461.65
List Price:  DH646.35
You save:  DH184.69
L866.83
List Price:  L1,213.63
You save:  L346.80
ден2,710.27
List Price:  ден3,794.60
You save:  ден1,084.32
MOP$402.78
List Price:  MOP$563.93
You save:  MOP$161.14
N$900.89
List Price:  N$1,261.32
You save:  N$360.43
C$1,838.58
List Price:  C$2,574.16
You save:  C$735.58
रु6,870.64
List Price:  रु9,619.45
You save:  रु2,748.80
S/183.77
List Price:  S/257.30
You save:  S/73.52
K204.83
List Price:  K286.78
You save:  K81.94
SAR187.49
List Price:  SAR262.51
You save:  SAR75.01
ZK1,362.87
List Price:  ZK1,908.13
You save:  ZK545.25
L222.63
List Price:  L311.70
You save:  L89.07
Kč1,095.56
List Price:  Kč1,533.87
You save:  Kč438.31
Ft17,742.35
List Price:  Ft24,840.71
You save:  Ft7,098.36
SEK kr476.80
List Price:  SEK kr667.57
You save:  SEK kr190.76
ARS$56,802.89
List Price:  ARS$79,528.59
You save:  ARS$22,725.70
Bs345.28
List Price:  Bs483.43
You save:  Bs138.14
COP$208,716.74
List Price:  COP$292,220.14
You save:  COP$83,503.40
₡25,394.22
List Price:  ₡35,553.95
You save:  ₡10,159.72
L1,300.63
List Price:  L1,820.98
You save:  L520.35
₲398,520.56
List Price:  ₲557,960.67
You save:  ₲159,440.11
$U2,077.16
List Price:  $U2,908.19
You save:  $U831.03
zł187.28
List Price:  zł262.21
You save:  zł74.92
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.