Best practice for Rails third party API calls?

前端 未结 2 1862
一向
一向 2020-12-21 15:59

I have a rails app that calls a third party API for weather.

The problem is that the API call is generally very slow and sometimes fails. Showing the weather is no

2条回答
  •  无人及你
    2020-12-21 16:16

    The recommended way is to call to the API in the background (using a scheduler) and save the result in the database. Then in the controller you can get the data from the database and there won't be any delay.

提交回复
热议问题