What am I doing wrong in my attempts to use an async routine?

        Task { // #1
            await FetchInventory() // #4
            ... GlobalTemp = ... // #5 (after data is loaded)
        }
        InventoryData = GlobalTemp // #2
        CurrentInventory = try! JSONDecoder().decode(...) // #3

This is the order the statements are getting executed.
You need to do json decoding after await finished awaiting. And better do it without a global and camelCase the variables. Something like this:

        Task {
            let (data, response) = await FetchInventory()
            currentInventory = try! JSONDecoder().decode(..., from: data)
        }

You'd also need to manage "currentInventory" correctly (assuming your views are using it). See the recent thread with a similar setup.

1 Like