class Strapi::Connection

The singleton class representing the Faraday connection to Strapi

Public Class Methods

instance() click to toggle source
# File lib/strapi/connection.rb, line 7
def instance
  @instance ||= Faraday::Connection.new("#{ENV['STRAPI_HOST_URL']}/api") do |f|
    f.request :json
    f.response :json
    f.adapter :net_http
  end
end
jwt_token() click to toggle source
# File lib/strapi/connection.rb, line 15
def jwt_token
  @jwt_token ||= instance.post(
    'auth/local',
    identifier: ENV['STRAPI_IDENTIFIER'],
    password: ENV['STRAPI_PASSWORD']
  ).body['jwt']
end