Skip to main content
added 68 characters in body
Source Link
James
  • 225
  • 2
  • 6

I have an API that returns a JSON formatted array of users within a given pair of lat/ long bounds.

I'm using this data to plot a number of markers on a map, based on the location of each user. I also want to render a HTML list on each client request so that I can show the list of plotted users alongside the map.

What is the best way to get thisthe list HTML to the client?

To me it seems like an incorrect solution to return the HTML for the user list within the initial HTMLAPI call (response.html, or something);, although this feels like I'm shoe-horning functionality into an otherwise clean API response.

I also don't want to make two API calls (one for the initial data and one for the HTML), for obvious reasons (overhead).

Finally, I don't want to generate the HTML client-side (in JavaScript), as I already have a class to do this for me server-side.

What options does that leave me with?

Thanks

I have an API that returns a JSON formatted array of users within a given pair of lat/ long bounds.

I'm using this data to plot a number of markers on a map, based on the location of each user. I also want to render a HTML list on each client request so that I can show the list of users alongside the map.

What is the best way to get this HTML to the client?

To me it seems like an incorrect solution to return the HTML for the user list within the initial HTML call (response.html, or something); this feels like I'm shoe-horning functionality into an otherwise clean API response.

I also don't want to make two API calls, for obvious reasons (overhead).

Finally, I don't want to generate the HTML client-side (in JavaScript), as I already have a class to do this for me server-side.

What options does that leave me with?

Thanks

I have an API that returns a JSON formatted array of users within a given pair of lat/ long bounds.

I'm using this data to plot a number of markers on a map, based on the location of each user. I also want to render a HTML list on each client request so that I can show the list of plotted users alongside the map.

What is the best way to get the list HTML to the client?

To me it seems like an incorrect solution to return the HTML for the user list within the initial API call (response.html, or something), although this feels like I'm shoe-horning functionality into an otherwise clean API response.

I also don't want to make two API calls (one for the initial data and one for the HTML), for obvious reasons (overhead).

Finally, I don't want to generate the HTML client-side (in JavaScript), as I already have a class to do this for me server-side.

What options does that leave me with?

Thanks

Source Link
James
  • 225
  • 2
  • 6

Returning view code in an API response

I have an API that returns a JSON formatted array of users within a given pair of lat/ long bounds.

I'm using this data to plot a number of markers on a map, based on the location of each user. I also want to render a HTML list on each client request so that I can show the list of users alongside the map.

What is the best way to get this HTML to the client?

To me it seems like an incorrect solution to return the HTML for the user list within the initial HTML call (response.html, or something); this feels like I'm shoe-horning functionality into an otherwise clean API response.

I also don't want to make two API calls, for obvious reasons (overhead).

Finally, I don't want to generate the HTML client-side (in JavaScript), as I already have a class to do this for me server-side.

What options does that leave me with?

Thanks