PHP code example of nnjeim / fetch
1. Go to this page and download the library: Download nnjeim/fetch library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nnjeim / fetch example snippets
php artisan vendor:publish --provider="Nnjeim\Fetch\FetchServiceProvider"
use Nnjeim\Fetch\FetchHelper;
private $fetch;
public function __construct(FetchHelper $fetch) {
$this->fetch = $fetch;
}
.
.
.
return $this->fetch
->setBaseUri('https://someapi.com')
->get('countries');
Set the http headers
@return $this setHeaders(array $headers)
Sets the type of the request to async.
@return $this setAsync()
Sets the body format to query.
@return array get(?string $url = null, ?array $data = null)
Sets the body format to form-params.
@return array post(?string $url = null, ?array $data = null)
Sets the body format to form-params.
@return array put(?string $url = null, ?array $data = null)
Sets the body format to query.
@return array delete(?string $url = null, ?array $data = null)
Sets the body format to multipart.
@return array upload(?string $url = null, ?array $data = null)
@return array
[
'response' => ...,
'status' => ...,
];