O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Fetching the product detail

Let's examine the FetchProductDetail function defined in the productdetail.go source file in the client/handlers folder:

func FetchProductDetail(productChannel chan *models.Product, productTitle string) {  data, err := xhr.Send("GET", "/restapi/get-product-detail"+"/"+productTitle, nil)  if err != nil {    println("Encountered error: ", err)    println(err)  }  var product *models.Product  json.NewDecoder(strings.NewReader(string(data))).Decode(&product)  productChannel <- product}

This function is responsible for making the XHR call to the Rest API endpoint on the server that provides the product data. The function takes in a product channel and a product title as input arguments. We make the XHR call by calling the Send ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required