Moya: Html code in response object

Created on 24 Apr 2018  路  7Comments  路  Source: Moya/Moya

pod 'Moya/RxSwift', '~> 11.0'

Hi im' getting from server strings like in an example. Is there any tool in Moya to decode these html characters in response to normal string which I could use in labels?

example "Who wrote "Harry Potter"?"   
question

All 7 comments

you can use

 case let .success(moyaResponse):
                moyaResponse.mapString()

Don鈥檛 forgot handle do/catch here

And statuscode filtering before mapping

Yes exactly right https://github.com/SeRG1k17

thanks for response but when i have code like this

 self.provider.rx.request(.getObjects).debug().map(ObjectsList.self).asObservable().subscribe(
                onNext: { [weak self] model in
                    guard let objects = model.list, let firstObject = objects.first else {return}
                    self?.firstObject.value = firstObject
                    onNext(objects)
                },
                onError: { error in
                    print(error.localizedDescription)
            }).disposed(by: self.disposeBag)
        }

And this "firstObject" is a class object with property "text" and in this "text" sometimes i'm getting this html code

@Pawlo1501 I don't think that Moya has any function to parse the HTML strings (@SD10 correct me if I am wrong).

Btw, with the suggestion from @kaleemozitech you can only map the entire response as string.

Ok thanks all for your help!

Was this page helpful?
0 / 5 - 0 ratings