-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.js
27 lines (25 loc) · 809 Bytes
/
http.js
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
// format of a typical API call, http request
const httpRequest = {
// describe destination server
host: 'localhosot',
port: 8080,
// describe purpose of requests
method: 'POST', //GET(retrieve from server), POST(provide data to server) DELETE, ect
// domain/RESOURCES/parameters
path: '/payments',
// collection of key-value pairs - defines body as json
headers: {
'content-type': 'application/json',
'content-length': 51,
},
// data request is sending to server
body: '{"data": "This is a piece of data in JSON format."}'
}
const httpResponse = {
statusCode: 200, //404 means not found
headers: {
'acess-control-allow-origin': "https://www.algoexpert.io",
'content-type': 'application/json'
},
body: '{}'
}