Answer the question
In order to leave comments, you need to log in
How can I automatically update the data on the page without reloading?
I am making a website for myself with information on the cost of a particular cryptocurrency. And I faced the problem of how to update the price, for example, for bitcoin, without reloading the page, as on COINMARCETCAP . I find out the price through api Binance like this
class MainController extends Controller
{
public function index(){
$url = Http::get('https://api.binance.com/api/v3/ticker/price');
$json = json_decode($url, true);
$tikers = collect($json);
$btc = $tikers->where('symbol','BTCUSDT')->pluck('price')->first();
return view('welcome', [
'btc' => round($btc,2),
]);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question