FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
parse-server/src/httpRequest.js at master · PocketPro/parse-server · GitHub
PocketPro
/
parse-server
Public
forked from
parse-community/parse-server
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
parse-server
/
src
/
httpRequest.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (42 loc) · 1.26 KB
Breadcrumbs
parse-server
/
src
/
httpRequest.js
Copy path
File metadata and controls
43 lines (42 loc) · 1.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var
request
=
require
(
"request"
)
,
Parse
=
require
(
'parse/node'
)
.
Parse
;
module
.
exports
=
function
(
options
)
{
var
promise
=
new
Parse
.
Promise
(
)
;
var
callbacks
=
{
success
:
options
.
success
,
error
:
options
.
error
}
;
delete
options
.
success
;
delete
options
.
error
;
if
(
options
.
uri
&&
!
options
.
url
)
{
options
.
uri
=
options
.
url
;
delete
options
.
url
;
}
if
(
typeof
options
.
body
===
'object'
)
{
options
.
body
=
JSON
.
stringify
(
options
.
body
)
;
}
request
(
options
,
(
error
,
response
,
body
)
=>
{
var
httpResponse
=
{
}
;
httpResponse
.
status
=
response
.
statusCode
;
httpResponse
.
headers
=
response
.
headers
;
httpResponse
.
buffer
=
new
Buffer
(
response
.
body
)
;
httpResponse
.
cookies
=
response
.
headers
[
"set-cookie"
]
;
httpResponse
.
text
=
response
.
body
;
try
{
httpResponse
.
data
=
JSON
.
parse
(
response
.
body
)
;
}
catch
(
e
)
{
}
// Consider <200 && >= 400 as errors
if
(
error
||
httpResponse
.
status
<
200
||
httpResponse
.
status
>=
400
)
{
if
(
callbacks
.
error
)
{
return
callbacks
.
error
(
httpResponse
)
;
}
return
promise
.
reject
(
httpResponse
)
;
}
else
{
if
(
callbacks
.
success
)
{
return
callbacks
.
success
(
httpResponse
)
;
}
return
promise
.
resolve
(
httpResponse
)
;
}
}
)
;
return
promise
;
}
;
Back
|
FazBrowse Home
|
New Git URL