Rails: get values of http response

后端 未结 1 1652
暗喜
暗喜 2021-01-03 17:40

In rails I made a post to an api and got a response, but I don\'t know how to get through the information and find the value of the \"code\" variable.

$ resp         


        
相关标签:
1条回答
  • 2021-01-03 17:49

    Parse the response content with JSON.parse:

    require 'json'
    
    ...
    
    data = JSON.parse(response.body)
    data['button']['code'] # => "dfhdsg7f23hjgfs7be7"
    
    0 讨论(0)
提交回复
热议问题