yattee/Model/PopularVideosProvider.swift

19 lines
473 B
Swift
Raw Normal View History

2021-06-10 22:50:10 +00:00
import Alamofire
import Foundation
import SwiftyJSON
final class PopluarVideosProvider: DataProvider {
@Published var videos = [Video]()
func load() {
DataProvider.request("popular").responseJSON { response in
switch response.result {
case let .success(value):
self.videos = JSON(value).arrayValue.map { Video($0) }
case let .failure(error):
print(error)
}
}
}
}