I have a function that fetchs a json data from a server and it must fetch the data if only the condition is met, but it excutes the block even if the condition is false
const getOfferingCourses = async () => {
    if (typeof loggerInfo === "object") {
      if (typeof loggerInfo.section) {
        const formdata = new FormData();
        formdata.append("getOfferingCourse", loggerInfo.section);
        let dep = await fetch(baseUrl + "enroll.php", {
          method: "POST",
          headers: {
            Accept: "application/json",
          },
          body: formdata,
        });
        let depa = await dep.json();
        if (typeof depa !== "undefined") {
          if (depa.status === "success") {
            setOffeing(depa.data.offering);
            setOffCourses(depa.data.courses);
          }
        }
      }
    }
  }
this is the error I got:
Uncaught (in promise) TypeError: Cannot read properties of null (reading 'section')
    at getSchedule (s-schedule.js:43:1)
    at s-schedule.js:61:1
    at commitHookEffectListMount (react-dom.development.js:23150:1)
    at commitPassiveMountOnFiber (react-dom.development.js:24926:1)
    at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
    at commitPassiveMountEffects_begin (react-dom.development.js:24878:1)
    at commitPassiveMountEffects (react-dom.development.js:24866:1)
    at flushPassiveEffectsImpl (react-dom.development.js:27039:1)
    at flushPassiveEffects (react-dom.development.js:26984:1)
    at react-dom.development.js:26769:1
 
     
    