title: Filtering and looping data in json response swift
body: <p>I'm a beginner and still learn about Swift. I wanna get the data only if they have the same ID and also I make a looping using &quot;for&quot;. It'll check if there are no data with the same ID anymore, it'll stop looping. Here is my code</p>
  <pre><code>    AF.request(url, method: .get, parameters: params, encoding: URLEncoding.default, 
       headers: header)
      .validate()
          .responseJSON { (response) in
              
              guard let data = response.data else {return}
  
              do{
                  let dataTagihan = try JSONDecoder().decode(Tagihan.self, from: data)
                  
  
                  let tagihanId = dataTagihan.data[0].tagihanId
                  let memberId = dataTagihan.data[0].memberId
                  let saveMember = KeychainWrapper.standard.set(memberId, forKey: &quot;memberId&quot;)
                  let saveTagihanId = KeychainWrapper.standard.set(tagihanId, forKey: 
                   &quot;tagihanId&quot;)
                  print(&quot;Tagihan Saved \(saveTagihanId)&quot;)
                  print(&quot;MemberId \(saveMember)&quot;)
                  
                  for var item in dataTagihan.data {
                      self.tagihan = dataTagihan.data.filter({ (value) -&gt; Bool in
                          if value.memberId == self.member {
                              item.memberId = self.member!
                          }
                           return value.memberId == self.member
                      })
                      
                      DispatchQueue.main.async {
                          self.tableView.reloadData()
                      }
                  }
   
              } catch{
                  print(&quot;error\(error)&quot;)
              }
      }
  </code></pre>
  <p>I do this code and the result is I only get one data with the same ID and the &quot;for&quot; loop is not working. I really need your help. thank you in advance</p>