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

Can someone teach me that CombineMoya post request is not working. #2319

Open
Shekhar-Das opened this issue Sep 25, 2023 · 1 comment
Open

Comments

@Shekhar-Das
Copy link

Version of Moya 15.0.0

Please wrap code blocks in backticks, like so:

func loginCombine()

{   let provider = MoyaProvider<API>()
    
    let cancellable = provider.requestPublisher(.login(phone: "087878787", password: "45454"))
    .sink(receiveCompletion: { completion in
        switch completion {
        case .finished:
            print("Network request failed:")
            break // Request completed successfully
        case .failure(let error):
            print("Network request failed: \(error)")
        }
    }, receiveValue: { response in
        if let statusCode = (response.response)?.statusCode {
            print("Status Code: \(statusCode)")
        }
        // Handle the response data as needed
    })
}

Please give us any sample code so that we can check this.
Also note that pod 'Moya/Combine', '~> 15.0' import CombineMoya is showing No such module 'CombineMoya'

@Shekhar-Das Shekhar-Das changed the title CombineMoya post request is not working. Can someone teach me that CombineMoya post request is not working. Sep 25, 2023
@WoodyHang
Copy link

WoodyHang commented Oct 10, 2023

Do not write the provider and cancellable inside the method. It should be used as a class attribute and hold

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

2 participants