Different api responses, not getting handled in code. Need to parse the array but my code expecting dictionary, I am not getting where to change. Please guide. Below is code:
func fetchProducts() {
    print("Page no\(String(describing: filter.page) )")
    NetworkHelper().makeAPIRequest(forAPI: .getProducts(forProduct: filter), responseType: ProductsDescription.self) { [weak self] (result) in
        guard let `self` = self else { return }
        switch result{
        case .error(let error):
            self.delegate?.ProductListing(self, didGetError: error)
        case .success(let response,let responseMsg):
            print("success")
            guard let resp = response,let products = response?.data else {
                return
            }
            if self.filter.page == 1 {
                self.products = []
            }
                if products.count > 0 {
                    self.products.append(contentsOf: products)
                    self.filter.page? += 1
                }
            self.delegate?.ProductListing(self, didSuccessProductListingDataWithMsg: nil)
            self.isInProgress = false
        }
    }
}
// Updated:
class ProductsDescription: Codable {
var data: [Product]?
enum CodingKeys: String, CodingKey {
    case data
}
required init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        let dataJSON = try values.decodeIfPresent(JSONModel.self, forKey: .data)
            if let productsData = try dataJSON?.rawData() {
                self.data = try JSONDecoder().decode([Product].self, from: productsData)
            }
        }
}
Api response:
{
"page" : "1",
"data" : [
{
  "options" : [
    {
      "value" : "Black berries",
      "key" : 128
    }
  ],
  "product_name" : "Fresh",
  "old_price" : "$10.00",
  "prodt_name" : "Exotic Fruits",
  "is_favorite" : 1,
  "product_rating" : 0,
  "product_id" : "13",
  "user_id" : "135",
  "brand_id" : "126",
  "selprod_id" : "128",
  "product_veg_status" : "1",
  "user_name" : "raj yadav",
  "product_price" : "$10.00",
  "prodcat_id" : "211",
  "discounted_price" : "-0% Off",
  "product_name" : "Black berries",
  "special_price_found" : "0",
  "selprod_stock" : "1000",
  "selprod_min_order_qty" : "1",
  "product_model" : "b44"
},
Error:
typeMismatch(Swift.Dictionary<Swift.String, Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Dictionary<String, Any> but found an array instead.", underlyingError: nil)) 
In short problem is when response comes as below:
  "data" : [ 
            {
If comes this way, it works fine:
 "data": { 
          "products": [ 
