package main import ( "fmt" "log" "net/http"
"github.com/gorilla/mux" ) func main() { router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/todos/{todoId}", getCallHistory) log.Fatal(http.ListenAndServe(":8080", router)) } func GetcallHistory(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) todoId:= vars["todoId"] fmt.Fprintln(w, "GetmemberId:", todoId}) callRemoteapi(todoId) } func callRemoteapi(id string){ fmt.Println("Starting the application...") fmt.Println("The value of id is", id) response, err := http.Get("https://jsonplaceholder.typicode.com/posts/{id}") if err != nil { fmt.Printf("The HTTP request failed with error %s\n", err) } else { data, _ := ioutil.ReadAll(response.Body) fmt.Println(string(data)) } } In the above code, I am trying to pass Id value in the https://jsonplaceholder.typicode.com/posts/{id}. I want this remote api to take the id as parameter and return the data in the json format. Any help is Appreciated. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.