How can I return 2 parameters from 1 api-call

I am trying to create an API that stores sql-queries in sql db. It returns the query nice and retrieve the result of this query correct.

query, page = Getquery(path)

However I want also to store which html page it should use. As one page could be reused to many queries (same template but populated with different data).

The result is that the page name (users) is returned in as a string plus the result as json ([{usr…)

fmt.Fprintf(w, "%s %s", page, json)

users [{“usr_date”:“2020-06-01T00:00:00Z”,“usr_id”:4, etc…

This is no problem to do this without using an API. As you can use query result directly. But how do I do this using a REST API?

I have 3 questions.

  1. Is it better to return the page + json in another format?
  2. Or how could I read the returned as 2 separate parameters?
  3. Or is there other ways to tell how one query should use a certain html page?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.