Unable to fetch any request on start

This is also using cloudflare-workers to get endpoints ect…
I am using wrangler.

When fetching a request on start, it’ll never start using await fetch nor fetch().then();
Instead it’ll just give a 522.

const worker = require('cloudflare-workers');

function postLog() {
    fetch('url that works perfectly fine').then(e => e.json()).then(e => {
        apidata = e; 
    return true;

addEventListener('fetch', async (event) => {

This is so frustrating please help.