mercredi 27 juin 2018

how to use rest-client to display specific data in rails

i connect with api to display specific data but not how to use this rails . not know put code in model or controller

require 'rest-client'
require 'json'

url = 'https://xxxx.restdb.io/rest/data'

headers = 
{
    'content-type': "application/json",
    'x-apikey': "-------",
    'cache-control': "no-cache"
}
req = RestClient.get(url, headers)

we = JSON.parse(req.body)

p we

Aucun commentaire:

Enregistrer un commentaire