carson-katri / swift-request

Declarative HTTP networking, designed for SwiftUI
MIT License
727 stars 41 forks source link

RequestChain nil data #54

Closed ca13ra1 closed 3 years ago

ca13ra1 commented 3 years ago

I'm using RequestChain and it seemed to be working just fine. Now I'm receiving nil data when checking the errors. The URL is valid because I'm getting correct data from other chain requests in the chain. I'm seeing a strange error in Xcode output w_protocol_get_quic_image_block_invoke dlopen libquic failed.

Even removing the working chain requests to see if maybe I was sending too many requests at once didn't solve the issue, still nil data when checking with two requests in the chain. The API is working correctly, printed the URL and verified the data is valid.

func chainRequest() {
    RequestChain {
        Request.chained { (data, err) in
            Url("VALID_URL_AUTH")
            Method(.post)
            Query(["user": "USER_NAME", "password": "PASSWORD"])
            Header.UserAgent(.firefoxMac)
        }
        Request.chained { (data, err) in
            let json = try? Json(data[0]!)
            Url("VALID_API_URL")
            Header.Authorization(.bearer(json!["TOKEN"].string))
            Query(["KEY": "VALUE"])
            Method(.get)
            Header.UserAgent(.firefoxMac)
        }
    }
    .call { (data, errors) in
        print("\(String(describing:errors))")
    }
}
carson-katri commented 3 years ago

err should be nil when there is valid data returned. Just want to clarify, are data and err both nil?

ca13ra1 commented 3 years ago

error is [nil, nil, nil, nil, nil]. Then data is [Optional(383 bytes), Optional(161 bytes), Optional(336 bytes), Optional(7708 bytes), Optional(8184 bytes)]

ca13ra1 commented 3 years ago

Solved! I apparently had something incorrect in my Codable data. Will close this issue. 🤦🏻‍♂️