I am quite new to React Native and JS and have recently purchased a React Native template which has a Dummy DB.
Ideally Id like it to pull data from an external JSON (api) which is being generated from a PHP website we already have running.
Here is the Dummy data file:
import { DoctorModel, TreatmentModel, CampaignModel, EventModel} from "../models";export const doctorsList: DoctorModel[] = [ { ##JSON HERE## } ];export const treatmentsList: TreatmentModel[] = [ { ##JSON HERE## } ];export const campaignList: CampaignModel[] = [ { ##JSON HERE## } ];export const eventList: EventModel[] = [ { ##JSON HERE## } ];
I want it to export as the same values as above so it will work seamlessly with the current app configuration.
I have tried the following...
export const doctorsList: DoctorModel[] = () => fetch(' ##LINK TO API## ') .then((response) => response.json());
But got this error:
Type '() => Promise<any>' is missing the following properties from type 'DoctorModel[]': pop, push, concat, join, and 27 more.
I have looked all over here and other platforms for a solution but cant find anything.
Again the ideal outcome would for it to work exactly how it would if I manually typed the JSON in as seen in the first code snippet.
Any help is much appreciated, still trying to wrap my head around React! :)