Problem in Return type

public shared func getRoleProfile(name : types.Name) : async ?types.Profile {
    role.getProfile(name);
  };

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

public func getProfile(name : types.Name) : async ?types.Profile{
      profiles.get(name);
    };

I am getting an error in the function getRoleProfile in main.mo. The error is

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

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 difference? - Stack Overflow

1 Like

Thanks you. It’s works perfectly.