fetch()

This is the static method that will help you get results from a website path with $options are custom settings that you include from constants available from PHP.

You can see about here: https://www.php.net/manual/en/function.curl-setopt.php

/**
 * @param string $url
 * @param array<string|null, string|array> $options
 * @return Promise when Promise resolve InternetRequestResult and when Promise reject Error
 * @throws Throwable
 * @phpstan-param array{method?: string, headers?: array<int, string>, timeout?: int, body?: array<string, string>} $options
 */
public static function fetch(string $url, array $options = []) : Promise;

For example, I want to get a simple result without adding custom settings:

$url = "https://www.google.com/";

System::fetch($url)->then(function($value) {
    var_dump($value);
})->catch(function($reason) {
    var_dump($reason);
});

Last updated