Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Problems with enumation based Network Intance #76

Open
ttuygun opened this issue Jul 2, 2017 · 3 comments
Open

Q: Problems with enumation based Network Intance #76

ttuygun opened this issue Jul 2, 2017 · 3 comments

Comments

@ttuygun
Copy link

ttuygun commented Jul 2, 2017

I've got response from the following code

    let request = Request.get("https://jsonplaceholder.typicode.com/posts/1")

        // Make a call
        Malibu.request(request)
            .validate()
            .toJsonDictionary()
            .then({ dictionary -> Post in
                print(dictionary)
                return try Post.init(object: dictionary)
            })
            .done({ posts in
                // Handle response data
                print(post)
            })
            .fail({ error in
                // Handle errors
                print(error)
            })
            .always({ _ in
                // Hide progress bar
            })

but when I define the API like network instance which named jsonPlaceholder. I don't any response, error, log. Nothing printed. No breakpoint entered to done, fail, or then.

enum JSONPlaceholderAPI: RequestConvertible {
    
    case getPost(id: String)
    
    static var baseUrl: URLStringConvertible? = "https://jsonplaceholder.typicode.com/"
    
    static var headers: [String: String] = [:]
    
    public var request: Request {
        switch self {
        case .getPost(let id):
            return Request.get("posts/\(id)")
        }
    }
}

  let jsonPlaceholder = Networking<JSONPlaceholderAPI>()
        
        jsonPlaceholder.request(.getPost(id: "1"))
            .validate()
            .toJsonDictionary()
            .then({ dictionary -> Post in
                print(dictionary)
                return try Post.init(object: dictionary)
            })
            .done({ posts in
                // Handle response data
                print(posts)
            })
            .fail({ error in
                // Handle errors
                print(error)
            })
            .always({ _ in
                // Hide progress bar
            })
@vadymmarkov
Copy link
Owner

Hi @ttuygun! My first guess is that your networking and/or promise instances are deallocated. Check this answer:
https://github.com/hyperoslo/Malibu/issues/73#issuecomment-309505251

@ttuygun
Copy link
Author

ttuygun commented Jul 12, 2017

It don't work :(

@onmyway133
Copy link
Contributor

@ttuygun Hi, without an example project, it's hard to tell. Can you replicate it in an example project and zip that to us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants