Trying to grab the top 5 tracks of an artist in a simple Sinatra app, but I get a wrong number of arguments regardless of the number of arguments given
require 'rubygems'
require 'bundler'
Bundler.setup
require 'sinatra'
require 'json'
require 'rest-client'
require 'rspotify'
require 'open-uri'
require 'nokogiri'
require 'rspotify/oauth'
get '/' do
"Top 5 Tunes by The National on Spotify"
RSpotify.authenticate('12345678abcdef', '987654321xyz')
artist = RSpotify::Artist.find('2cCUtGK9sDU2EoElnk0GNB')
tracks = artist.top-tracks.limit(5)
end
Error received:
2022-09-20 10:07:16 - ArgumentError - wrong number of arguments (given 2, expected 1):
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:in initialize' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:innew'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:in parse' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rspotify-2.11.1/lib/rspotify/connection.rb:32:inauthenticate'
national.rb:19:in block in <main>' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in block in compile!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:inblock (3 levels) in route!'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1042:in route_eval' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:inblock (2 levels) in route!'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1071:in block in process_route' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:incatch'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in process_route' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1021:inblock in route!'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in each' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:inroute!'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1140:in block in dispatch!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:inblock in invoke'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in catch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:ininvoke'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1135:in dispatch!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:inblock in call!'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in block in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:incatch'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:incall!'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:938:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/xss_header.rb:18:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/path_traversal.rb:16:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/json_csrf.rb:26:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/frame_options.rb:31:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/logger.rb:17:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/common_logger.rb:38:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:255:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:248:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/head.rb:12:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/method_override.rb:24:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/show_exceptions.rb:22:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:218:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1993:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in block in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1769:insynchronize'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/configuration.rb:252:incall'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/request.rb:77:in block in handle_request' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:340:inwith_force_shutdown'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/request.rb:76:in handle_request' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/server.rb:441:inprocess_client'
/Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
Trying to grab the top 5 tracks of an artist in a simple Sinatra app, but I get a wrong number of arguments regardless of the number of arguments given
Error received: 2022-09-20 10:07:16 - ArgumentError - wrong number of arguments (given 2, expected 1): /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:in
initialize' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:in
new' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/json-2.1.0/lib/json/common.rb:156:inparse' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rspotify-2.11.1/lib/rspotify/connection.rb:32:in
authenticate' national.rb:19:inblock in <main>' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:inblock in compile!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in
block (3 levels) in route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1042:inroute_eval' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in
block (2 levels) in route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1071:inblock in process_route' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in
catch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:inprocess_route' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1021:in
block in route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:ineach' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in
route!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1140:inblock in dispatch!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in
block in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:incatch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in
invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1135:indispatch!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in
block in call!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:inblock in invoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in
catch' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:ininvoke' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in
call!' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:938:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/xss_header.rb:18:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/path_traversal.rb:16:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/json_csrf.rb:26:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-protection-2.2.2/lib/rack/protection/frame_options.rb:31:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/logger.rb:17:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/common_logger.rb:38:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:255:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:248:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/head.rb:12:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/rack-2.2.4/lib/rack/method_override.rb:24:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/show_exceptions.rb:22:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:218:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1993:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:inblock in call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1769:in
synchronize' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:incall' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/configuration.rb:252:in
call' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/request.rb:77:inblock in handle_request' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:340:in
with_force_shutdown' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/request.rb:76:inhandle_request' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/server.rb:441:in
process_client' /Users/pjhagerty/.rvm/gems/ruby-3.0.0/gems/puma-5.6.4/lib/puma/thread_pool.rb:147:in `block in spawn_thread'