I try to check if I have an error in my token, In my view it works like this and it seems to be Ok :
<% if @token['error'].present?%>
<%= @token['error']%> // display the message of the error
<%= flash[:error]%> //display ERROR
<% else %>
<%= @token%> // display the token
<p>Ok</p>
<%end%>
But in my controller, I can't do that :
if @token['error'].present?
flash[:error] = "ERROR"
else
@token = HTTParty.post('https://mooncard23-sandbox.biapi.pro/2.0/auth/token/access',
body: {
client_id: XXXXXXXXXX,
client_secret: "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY",
code: @decoded_code
}
)
end
I have the error "undefined method `[]' for nil:NilClass". Do you know how to check if my token return an error ?
Aucun commentaire:
Enregistrer un commentaire