I'm using Vapor to try to get an XML file from another server, the problem is I don't know how to convert the response body to a swift String.
let bikesResponse = try drop.client.get("http://www.c-bike.com.tw/xml/stationlistopendata.aspx")
let bodyBytes = bikesResponse.body
let string = String(bytes) // <-- WHAT DO I DO HERE?
Thanks
Ah, ok I figured it out eventually.
let bikesResponse = try drop.client.get("http://www.c-bike.com.tw/xml/stationlistopendata.aspx")
if let bodyBytes = bikesResponse.body.bytes {
let string = String(bytes: bodyBytes, encoding: String.Encoding.utf8) {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With