I am trying to get a particular logged in ID's data in profile but I am unable to get it I have viewed many links but its not working for me. Below is my function that I have used to get data
Function
func getCompanyFunc() {
let empURL = URL(string: "http://172.16.1.22/Get-Company-API/get-companies/")
URLSession.shared.dataTask(with: empURL!) { (data, response, error) in
do {
if error == nil {
self.getCompanyArray = try JSONDecoder().decode([CompanyDataProfile].self, from: data!)
for mainArr in self.getCompanyArray {
DispatchQueue.main.async {
let companyDefaultValue = UserDefaults.standard
if let userID = companyDefaultValue.string(forKey: "user_type_id") {
self.getComData = self.getCompanyArray.filter { $0.company_id == userID }
print("Company ID Profile=\(userID)")
self.companyName_lbl.text = mainArr.company_name
}
}
}
print("****Employee Data****\(self.getCompanyArray)")
}
}
catch {
print("Error in get JSON Data Employee\(error)")
}
}.resume()
}