I have an URL of API. I want to make an action in controller to get all data
BranchesController.cs:
public Task<IEnumerable<BranchVm>> GetAllAsync()
{
string baseUrl = "http://api.diamond.smart-gate.net/api/Branches/GetBranches";
var client = new HttpClient();
var task = client.GetStringAsync(baseUrl);
return task.ContinueWith<IEnumerable<BranchVm>>(innerTask =>
{
var json = innerTask.Result;
return JsonConvert.DeserializeObject<BranchVm[]>(json);
});
}
Branch.js:
columns: [
{
"data": 'branchArName',
"name": "branchArName",
"autoWidth": true,
"orderable": true
},
{
"data": 'branchEnName',
"name": "branchEnName",
"autoWidth": true,
"orderable": true,
},
],
ajax: {
url: "/Branches/GetAllAsync",
dataSrc: ''
}
It doesn't return any data but when I debug it , I have all data in innerTaslk.Result but var json equals null. so, I don't know why ?
ContinueWithstuff.