Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
763be9f1
Verified
Commit
763be9f1
authored
3 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: check header by rest api
parent
e440a937
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/data/datasource/server/restapi.mjs
+13
-5
13 additions, 5 deletions
source/data/datasource/server/restapi.mjs
with
13 additions
and
5 deletions
source/data/datasource/server/restapi.mjs
+
13
−
5
View file @
763be9f1
...
@@ -94,7 +94,10 @@ class RestAPI extends Server {
...
@@ -94,7 +94,10 @@ class RestAPI extends Server {
write
:
{
write
:
{
init
:
{
init
:
{
method
:
"
POST
"
,
method
:
"
POST
"
,
headers
:
null
,
headers
:
{
Accept
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
,
},
},
},
responseCallback
:
null
,
responseCallback
:
null
,
acceptedStatus
:
[
200
,
201
],
acceptedStatus
:
[
200
,
201
],
...
@@ -118,7 +121,9 @@ class RestAPI extends Server {
...
@@ -118,7 +121,9 @@ class RestAPI extends Server {
read
:
{
read
:
{
init
:
{
init
:
{
method
:
"
GET
"
,
method
:
"
GET
"
,
headers
:
null
,
headers
:
{
Accept
:
"
application/json
"
},
},
},
path
:
null
,
path
:
null
,
responseCallback
:
null
,
responseCallback
:
null
,
...
@@ -141,10 +146,9 @@ class RestAPI extends Server {
...
@@ -141,10 +146,9 @@ class RestAPI extends Server {
read
()
{
read
()
{
let
init
=
this
.
getOption
(
"
read.init
"
);
let
init
=
this
.
getOption
(
"
read.init
"
);
if
(
!
isObject
(
init
))
init
=
{};
if
(
!
isObject
(
init
))
init
=
{};
if
(
!
(
init
[
"
headers
"
]
instanceof
Headers
))
{
if
(
!
(
init
[
"
headers
"
]
instanceof
Headers
)
&&
!
isObject
(
init
[
"
headers
"
])
)
{
init
[
"
headers
"
]
=
new
Headers
();
init
[
"
headers
"
]
=
new
Headers
();
init
[
"
headers
"
].
append
(
"
Accept
"
,
"
application/json
"
);
init
[
"
headers
"
].
append
(
"
Accept
"
,
"
application/json
"
);
init
[
"
headers
"
].
append
(
"
X-Requested-With
"
,
"
XMLHttpRequest
"
);
}
}
if
(
!
init
[
"
method
"
])
init
[
"
method
"
]
=
"
GET
"
;
if
(
!
init
[
"
method
"
])
init
[
"
method
"
]
=
"
GET
"
;
...
@@ -166,7 +170,7 @@ class RestAPI extends Server {
...
@@ -166,7 +170,7 @@ class RestAPI extends Server {
write
()
{
write
()
{
let
init
=
this
.
getOption
(
"
write.init
"
);
let
init
=
this
.
getOption
(
"
write.init
"
);
if
(
!
isObject
(
init
))
init
=
{};
if
(
!
isObject
(
init
))
init
=
{};
if
(
!
(
init
[
"
headers
"
]
instanceof
Headers
))
{
if
(
!
(
init
[
"
headers
"
]
instanceof
Headers
)
&&
!
isObject
(
init
[
"
headers
"
])
)
{
init
[
"
headers
"
]
=
new
Headers
();
init
[
"
headers
"
]
=
new
Headers
();
init
[
"
headers
"
].
append
(
"
Accept
"
,
"
application/json
"
);
init
[
"
headers
"
].
append
(
"
Accept
"
,
"
application/json
"
);
init
[
"
headers
"
].
append
(
"
Content-Type
"
,
"
application/json
"
);
init
[
"
headers
"
].
append
(
"
Content-Type
"
,
"
application/json
"
);
...
@@ -206,6 +210,10 @@ class RestAPI extends Server {
...
@@ -206,6 +210,10 @@ class RestAPI extends Server {
function
fetchData
(
init
,
key
,
callback
)
{
function
fetchData
(
init
,
key
,
callback
)
{
let
response
;
let
response
;
if
(
init
?.
headers
===
null
)
{
init
.
headers
=
new
Headers
();
}
return
fetch
(
this
.
getOption
(
`
${
key
}
.url`
),
init
)
return
fetch
(
this
.
getOption
(
`
${
key
}
.url`
),
init
)
.
then
((
resp
)
=>
{
.
then
((
resp
)
=>
{
response
=
resp
;
response
=
resp
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment