I have a success function in my ajax call. The issue I am facing is I need to map the data that gets returned. Outside of this function it maps correctly, but not within. Any help
$.ajax({
url: "https://example.com",
type: 'Get',
headers: {
accept: "application/json;odata=verbose"
},
success: function(data) {
console.log(data);
vm.items = data;
data.Modules.map(function(module) {
if (module.Topics.length) {
var url, text
if (module.Topics[1]) {
url = module.Topics[1].Url
text = module.Topics[1].Title
} else {
url = module.Topics[0].Url
text = module.Topics[0].Title
}
}
return {
url,
text
}
})
},
})
}
},