Home > Enterprise >  React Native Calendar returns {"_U":0,"_V":0,"_W":null,"_X":
React Native Calendar returns {"_U":0,"_V":0,"_W":null,"_X":

Time:10-06

I am using expo-calendar and retrieving an object of calendars from a user's device.

After receiving the calendars I am using the calendar to retrieve the events from the individual calendars.

Upon requesting for the events I am receiving {"_U":0,"_V":0,"_W":null,"_X":null} when I log the requested event data.

Along with this I am receiving the error: [Unhandled promise rejection: Error: An exception was thrown while calling `ExpoCalendar.getEventsAsync` with arguments `(] at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in promiseMethodWrapper at node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name at http://127.0.0.1:19000/index.bundle?platform=ios&dev=true&hot=false&minify=false:321320:82 in getEventsAsync$ at Screens/Tasks_1.js:1018:15 in <global>

I believe this is because the request const events = Calendar.getEventsAsync() is waiting on a promise but I cannot determine what response it is waiting for. How can I correctly access the events?

useEffect(() => {
    (async () => {
//REQUEST PERMISSION TO ACCESS CALENDAR
      const { status } = await Calendar.requestCalendarPermissionsAsync();
      if (status === "granted") {
        const calendars = await Calendar.getCalendarsAsync(
          Calendar.EntityTypes.EVENT
        );
//LIST OF ALL CALENDARS ON DEVICE WITH ID's
        console.log("Here are all your calendars:");
        console.log({ calendars });
//GET EVENTS FROM A CALENDAR ON DEVICE WITH A GIVEN ID AND TIME RANGE
        const events = Calendar.getEventsAsync(
          calIDs,
          "2021-04-14T17:00:00.00Z",
          "2021-09-14T17:00:00.00Z"
        );
//THIS LOGS {"_U":0,"_V":0,"_W":null,"_X":null}
        console.log("EVENTS"   JSON.stringify(events));
      }
    })();
  }, []);

CodePudding user response:

{"_U":0,"_V":0,"_W":null,"_X":null} this is happen probably because you didn't add await keyword before Calendar.getEventsAsync !!

  • Related