2016-07-22 42 views
1

我正在實現服務,我必須創建動態http發佈請求,我的代碼如下。如何在榆樹中創建動態http正文

postRequest: Int -> Http.Request 
postRequest catId = 
     let 
      body = 
       """{"categoryId:"""++catId++""","coupon":false,"domainId":1,"locations":[],"onlineMenu":false,"onlineOrder":false,"pageNo":1,"pageSize":10,"reservation":false,"searchText":"","subcategories":[]}""" 
     in 
      { verb = "POST" 
       , headers = 
        [("Content-Type", "application/json") 
        ] 
       , url = "http://xyz/businesses/list" 
       , body = Http.string body 
      } 

,但我收到的一些錯誤 如何連接的CATID在身體和CATID爲整型。

請有人建議我在執行過程中做了什麼錯誤。

回答

2

當你宣佈catId作爲IntString,所以 (++) : String -> String -> String不能沒有它。

在與字符串連接之前,可以使用toString : a -> String

"categoryId:" ++ (toString catId) 
+0

謝謝@Tosh的幫助! –