Problem in Return type

public shared func getRoleProfile(name : types.Name) : async ?types.Profile {

I am calling role.getProfile() function from my file. The function is define in file.
The defination of the function is

public func getProfile(name : types.Name) : async ?types.Profile{

I am getting an error in the function getRoleProfile in The error is

expression of type
  async<$getRoleProfile__14> ?Profile__764
cannot produce expected type

What will be the return type of this function?

Since the problems you’re walking through is the world async, basically you can’t do it immediately and have to wait for a bit until it can be done. You can solve this by adding the key word await in front of function you need, to satisfy the structure.

You can take a look at this post for a better understanding what’s the differences between async and sync.

Asynchronous vs synchronous execution, what is the main difference? - Stack Overflow

1 Like

Thanks you. It’s works perfectly.