xxxxxxxxxx
function fetchArticles(offset, limit, filter) {
return fetchGraphQL(
operationsDoc,
"articles",
{"offset": offset, "limit": limit, "filter": filter}
);
}
async function startFetchArticles(offset, limit, filter) {
const { errors, data } = await fetchArticles(offset, limit, filter);
if (errors) {
// handle those errors like a pro
console.error(errors);
}
// do something great with this precious data
console.log(data);
}
startFetchArticles(offset, limit, filter);
xxxxxxxxxx
response = Faraday.get('https://api.github.com/users/your_username')
r = JSON.parse(response.body, symbolize_names: true)
#OR
JSON.parse(response.body)
#'symbolize_names' turns the keys in this hash into symbols, not required
#JSON.parse is what turns the JSON object into a hash
xxxxxxxxxx
WEBHOOK_SECRET = 'webhook secret key';
post '/payload' do
request.body.rewind
body = request.body.read
signature = request.env['HTTP_X_TAWK_SIGNATURE']
unless verifySignature(body, signature))
// verification failed
end
// verification success
end
def verifySignature(body, signature)
digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), WEBHOOK_SECRET, body)
return digest == signature
end