title: How to pass data from backend to client in google endpoints?
body: <p>In my endpoint class in my android app, I return a Profile object which is an entity. I want to pass the data back to the frontend. </p>
  
  <p>What is the best way of doing this and where should the model be
  stored, in the frontend or in the backend, or perhaps in both?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>For example in an async task I do the following:</p>
  
  <pre><code>try {
      return mApi.saveProfile(firstName, lastName, birthday, userId).execute().getFirstName();
  } catch (IOException e) {
      return e.getMessage();
  }
  </code></pre>
  
  <p>This calls the endpoints backend method <code>saveProfile</code> which is located in a separate module in the android app. The method does this:</p>
  
  <pre><code>@ApiMethod(name = "saveProfile")
      public Profile saveProfile(@Named("firstName") String firstName,
                                 @Named("lastName") String lastName,
                                 @Named("birthday") String birthday,
                                 @Named("userId") String userId) {
          Profile profile = ofy().load().key(Key.create(Profile.class, userId)).now();
          if (profile == null) {
              profile = new Profile(userId, firstName, lastName, birthday);
          } else {
              profile.updateProfile(firstName, lastName, birthday);
          }
          ofy().save().entity(profile).now();
          return profile;
      }
  </code></pre>
  
  <p>This method returns a profile entity from the backend endpoints module to where it was called from, in this case, an async task located in the app module (client).</p>
  
  <p>Is it ok for me to use the profile object and add a dependency on the backend module, in order for me to use this object in my client or should I be returning a different object in the backend?</p>
  
  <p>In the method <code>saveProfile</code> there are many parameters, I would like to pass in an object which contains all these fields directly but how do I do this using endpoints as when I do I would need to add a dependency on the backend module so that the class is recognised? So should the profile entity be stored in the backend and should the profile form (saveProfile parameter) be located in the backend or client?</p>