mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 06:38:13 -05:00
🐛 Fix: handle empty request-body
This commit is contained in:
parent
c56d4efa79
commit
81e6acb29b
@ -29,7 +29,7 @@ class Server {
|
||||
})
|
||||
request.on('end', () => {
|
||||
try {
|
||||
postObj = JSON.parse(body)
|
||||
postObj = (body === '') ? {} : JSON.parse(body)
|
||||
} catch (err) {
|
||||
return handleResponse({
|
||||
response,
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user