Class: Strapi::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/strapi/connection.rb

Overview

The singleton class representing the Faraday connection to Strapi

Class Method Summary collapse

Class Method Details

.instanceObject



7
8
9
10
11
12
13
# 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_tokenObject



15
16
17
18
19
20
21
# 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