title: Correctly chain multiple promises in PromiseKit 6
body: <p>I'm using Promisekit 6 and have 3 functions defined, all of which return promises.
  the first fetches data from a local database and the second from an online API server. the third, Foo, checks if the data with a given id exists locally, otherwise it checks online and returns it.</p>
  
  <p>I'm having trouble figuring out how to correctly chain the promises. Below is what I came up with thus far, but I'm not certain if creating a new promise is a good idea.
  Any feedback is appreciated.
  Thanks :)</p>
  
  <pre><code>func daoClient.get(id: String) -&gt; Promise&lt;Any&gt; {
      return Promise { seal in
          do {
              let realm = try Realm()
              if let data = realm.object(ofType: DataEntity.self, forPrimaryKey: id) {
                  seal.fulfill(alert)
              } else {
                  seal.reject(Errors.DataError(error: "no data found with id \(id)"))
              }
          } catch {
              seal.reject(error)
          }
      }
  }
  
  func apiClient.get(id: String) -&gt; Promise&lt;swiftyJson.JSON&gt; {
      return self.oiRequestClient.request(self.endpoint, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil)
          .responseJSON()
          .compactMap { (arg) -&gt; JSON? in
              let json = JSON(arg.json)
  
              if let response = arg.response.response, response.statusCode &gt; 399 {
                  let error = json["error"].dictionary?.description
                  throw Errors.NetWorkError(error: error)
              } else {
                  return json
              }
          }
  }
  
  
  func Foo(id: String) -&gt; Promise&lt;Any&gt; {
      return Promise { seal in
          daoClient
              .get(id: id)
              .done { data in
                  seal.fulfill(data)
              }.recover { (error: Error) in
                  return self.apiClient
                  .get(id: id)
                  .done { data in
                      seal.fulfill(data)
                  }
              }.catch { error in
                  seal.reject(error)
              }
      }
  }
  </code></pre>