In this challenge episode you will put your existing knowledge about URLSession to the test in order to download and display data downloaded from the network.
Regarding your question, about wrapping session.data(from: url) in a task I imagine you are referring to the solved challenge.
In this scenario, using Task within the function may not be strictly necessary as the calling context already calls it in a task. If you were to call this method elsewhere, however, it could be beneficial to do so in a task within the function, but there’s no one-size-fits-all solution.
As for how we call the function within the button’s action, if I recall correctly Task is used there in order to avoid a compiler error about calling an async function in a non-concurrent fashion.
The nested task within the fetchMusic function is unneeded as the action closure within the Button is in an async context. Wouldn’t it be better practice to let the consumer of the function be in an async context to have more flexibility / control of when you are / aren’t entering in a background thread?