Skip to content

Commit

Permalink
🐛 Fix: handle empty request-body
Browse files Browse the repository at this point in the history
  • Loading branch information
Molunerfinn committed Dec 31, 2019
1 parent c56d4ef commit 81e6acb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Server {
})
request.on('end', () => {
try {
postObj = JSON.parse(body)
postObj = (body === '') ? {} : JSON.parse(body)
} catch (err) {
return handleResponse({
response,
Expand All @@ -53,7 +53,7 @@ class Server {
}
private listen = (port: number) => {
console.log(`server listen at ${port}`)
this.httpServer.listen(port).on('error', (err: ErrnoException) => {
this.httpServer.listen(port, '0.0.0.0').on('error', (err: ErrnoException) => {
if (err.errno === 'EADDRINUSE') {
console.log(`----- Port ${port} is busy, trying with port ${port + 1} -----`)
this.port += 1
Expand Down

0 comments on commit 81e6acb

Please sign in to comment.