Can this gem be used in an existing application
Closed this issue · 2 comments
We have a mature app that for good reason needs to change from writing to the database using AR to completely relying on an external API for getting and persisting data.
I thought this gem would get us 50% of the way there, but it doesn't seem to work.
I've set it up exactly like the README, just to see what it does. If I start a rails server, and hit localhost:3000
, this is what I get
Spyke (177.7ms) GET []
method=GET path=/ format=html controller=welcome action=default status=500 error='MultiJson::ParseError:795: unexpected token at '<HTML><HEAD>
<TITLE>Redirect</TITLE>
</HEAD>
<BODY>
<FONT face="Helvetica">
<big><strong></strong></big><BR>
</FONT>
<blockquote>
<TABLE border=0 cellPadding=1 width="80%">
<TR><TD>
<FONT face="Helvetica">
<big>Redirect (policy_redirect)</big>
<BR>
<BR>
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
Click <a href="http://www.gelifesciences.com/webapp/wcs/stores/servlet/catalog/en/GELifeSciences-/brands/deltavision/">here</a> if you are not automatically redirected.
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica">
</FONT>
</TD></TR>
<TR><TD>
<FONT face="Helvetica" SIZE=2>
<BR>
For assistance, contact your network support team.
</FONT>
</TD></TR>
</TABLE>
</blockquote>
</FONT>
</BODY></HTML>
'' duration=181.50 account=
Would be great if you could share a bit of the code, but it looks like you have it set up to hit an API that actually returns HTML and the current middleware you’re using is expecting JSON and therefore fails trying to parse the HTML as JSON?
What does the controller look like that is mapped to localhost:3000
and the model using Spyke?
There should be nothing inherent in Spyke that prevents you from using it in an existing application, as long as the gem dependencies are satisfied! 😉
Another thing you could do to get a bit more info, is to add some logging middleware to Faraday, for example:
# Gemfile
gem “faraday-conductivity”
# Middleware
# ...
c.use Faraday::Conductivity::ExtendedLogging, logger: Logger.new(Rails.root.join("log", "spyke.log"))
Hope you were able to work this out! Closing the issue for now 🙏