Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haiyen-payment
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
haiyen-payment
Commits
00a6931c
Commit
00a6931c
authored
Aug 31, 2026
by
tdgiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add header-aware GET/PATCH helpers with status code passthrough to ApiRequest
parent
cb12e735
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
4 deletions
+55
-4
ApiRequest.js
app/libs/ApiRequest.js
+55
-4
No files found.
app/libs/ApiRequest.js
View file @
00a6931c
...
@@ -256,12 +256,63 @@ exports.postOtherUrlWithHeader = function (apiName, param, headers, callback) {
...
@@ -256,12 +256,63 @@ exports.postOtherUrlWithHeader = function (apiName, param, headers, callback) {
}
}
// request ato API Host
// request ato API Host
request
(
options
,
function
(
err
,
httpResponse
,
body
)
{
request
(
options
,
function
(
err
,
httpResponse
,
body
)
{
var
statusCode
=
httpResponse
?
httpResponse
.
statusCode
:
undefined
;
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
body
);
callback
(
err
,
body
,
statusCode
);
}
else
if
(
httpResponse
.
statusCode
>=
200
&&
httpResponse
.
statusCode
<
300
)
{
}
else
if
(
statusCode
>=
200
&&
statusCode
<
300
)
{
callback
(
err
,
body
);
callback
(
err
,
body
,
statusCode
);
}
else
{
}
else
{
callback
(
body
);
callback
(
body
,
undefined
,
statusCode
);
}
});
};
exports
.
getOtherUrlWithHeader
=
function
(
apiName
,
param
,
headers
,
callback
)
{
if
(
typeof
(
param
)
===
'function'
)
{
callback
=
param
;
param
=
{};
}
var
url
=
apiName
;
for
(
var
k
in
param
)
{
url
+=
k
+
'='
+
param
[
k
]
+
'&'
;
}
var
options
=
{
method
:
'GET'
,
uri
:
url
,
headers
:
headers
,
json
:
true
};
request
(
options
,
function
(
err
,
httpResponse
,
body
)
{
var
statusCode
=
httpResponse
?
httpResponse
.
statusCode
:
undefined
;
if
(
err
)
{
callback
(
err
,
body
,
statusCode
);
}
else
if
(
statusCode
>=
200
&&
statusCode
<
300
)
{
callback
(
err
,
body
,
statusCode
);
}
else
{
callback
(
body
,
undefined
,
statusCode
);
}
});
};
exports
.
patchOtherUrlWithHeader
=
function
(
apiName
,
param
,
headers
,
callback
)
{
if
(
typeof
(
param
)
===
'function'
)
{
callback
=
param
;
param
=
{};
}
var
options
=
{
method
:
'PATCH'
,
uri
:
apiName
,
headers
:
headers
,
json
:
param
};
request
(
options
,
function
(
err
,
httpResponse
,
body
)
{
var
statusCode
=
httpResponse
?
httpResponse
.
statusCode
:
undefined
;
if
(
err
)
{
callback
(
err
,
body
,
statusCode
);
}
else
if
(
statusCode
>=
200
&&
statusCode
<
300
)
{
callback
(
err
,
body
,
statusCode
);
}
else
{
callback
(
body
,
undefined
,
statusCode
);
}
}
});
});
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment