Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
node-api
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
project-templates
web
node-api
Commits
ebd36637
Commit
ebd36637
authored
Apr 17, 2019
by
Vadym Gidulian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added proper Content-Type header for 4xx error
parent
230272f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
api.js
src/utils/api.js
+6
-2
No files found.
src/utils/api.js
View file @
ebd36637
...
@@ -20,7 +20,9 @@ module.exports = {
...
@@ -20,7 +20,9 @@ module.exports = {
await
requestValidator
(
req
,
res
,
_next
);
await
requestValidator
(
req
,
res
,
_next
);
if
(
nextWatcher
.
wasCalled
)
return
nextWatcher
.
doNext
();
if
(
nextWatcher
.
wasCalled
)
return
nextWatcher
.
doNext
();
}
catch
(
e
)
{
// Probably bad request
}
catch
(
e
)
{
// Probably bad request
return
res
.
status
(
400
).
send
(
e
.
message
);
return
res
.
status
(
400
)
.
set
(
'Content-Type'
,
'text/plain'
)
.
send
(
e
.
message
);
}
}
}
}
...
@@ -30,7 +32,9 @@ module.exports = {
...
@@ -30,7 +32,9 @@ module.exports = {
if
(
nextWatcher
.
wasCalled
)
return
nextWatcher
.
doNext
();
if
(
nextWatcher
.
wasCalled
)
return
nextWatcher
.
doNext
();
}
catch
(
e
)
{
// Operation error
}
catch
(
e
)
{
// Operation error
const
code
=
e
.
code
||
(
e
.
response
&&
e
.
response
.
code
);
const
code
=
e
.
code
||
(
e
.
response
&&
e
.
response
.
code
);
if
(
/^4
\d\d
/
.
test
(
code
))
return
res
.
status
(
code
).
send
(
e
.
message
);
if
(
/^4
\d\d
/
.
test
(
code
))
return
res
.
status
(
code
)
.
set
(
'Content-Type'
,
'text/plain'
)
.
send
(
e
.
message
);
return
next
(
e
);
return
next
(
e
);
}
}
...
...
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