So I created an SQL Database with a ton of information and a web service made in ASP.net Web API in order to make requests for data from the database. The client is a React-Native javascript app. I'm having issues trying to just isolate my JSON that I want from this weird Promise object. Yes, I feel like I'm missing the point of a Promise, but I just want to extract my data. Here's some code:
import RestClient from 'react-native-rest-client';
class FetchData extends RestClient
{
constructor()
{
super('https://electionswebservice.conveyor.cloud/Api')
}
getOffices()
{
return this.GET('/Offices');
}
getSpecificOffice(id)
{
return this.GET('/Offices/' + id.toString())
}
}
export default FetchData;
If called, getOffices() returns: https://i.stack.imgur.com/rfwW1.png
Sweet, all my data that I do want is in the _55 attribute of this Promise object. Based on all my searches, here's the closest I've been able to isolate what I need:
this.api = new FetchData();
this.api.getOffices().then(console.log);
This will return: https://i.stack.imgur.com/PQiAr.png
I haven't been able to return that array that I've been wanting. I want the array to get stored into a variable that I make in the SAME SCOPE :
this.api = new FetchData();
this.offices = this.api.getOffices()...;
How can I do that? (It's probably really obvious I'm probably having some kind of brainfart)