Why don't I get a HTTP status code from Firebase Server? Swift - Vapor server

388 Views Asked by At

I am writing to Firebase Database from a Vapor server using the Firebase REST API. Why don't I get a Status code in the header received? This would enable me to check if the write was successful or not.

headerReceived items line 83 in extensionPutRequestToUsersClaimBookingCleaner are

([Connection: "keep-alive", Cache-Control: "no-cache", Server: "nginx", Date: "Sun, 27 Aug 2017 21:47:25 GMT", Content-Type: "application/json; charset=utf-8", Content-Length: "1027", Strict-Transport-Security: "max-age=31556926; includeSubDomains; preload", Access-Control-Allow-Origin: "*"])

1

There are 1 best solutions below

1
On BEST ANSWER

The response's status code is returned in the status property rather than the headers property.

guard response.status == .created else {
  // not a 201 response
}