Code QuizAdvanced

Chaining a Dependent Request

Chaining an ID stream into a fetch produces a publisher of publishers.

Codeswift
func fetchProfile(id: Int) -> AnyPublisher<Profile, Never> {
    // network call returning a Profile
}

userIDPublisher // AnyPublisher<Int, Never>
    .map { id in
        fetchProfile(id: id)
    }
    .sink { profile in
        print(profile.name)
    }
    .store(in: &cancellables)

Why does this fail to compile / not deliver a Profile?