May Sale! All accounts are 40% off this week.

qTylok's avatar

How to setup a constructor for google maps api with Guzzle client

Hey, I tried to configurate a constructor for google maps api with Guzzle client but I have some problems with him I got this error

TypeError: Argument 1 passed to GuzzleHttp\Client::__construct() must be of the type array, string given, called in /var/www/html/app/Services/GoogleMapsAreaService.php on line 19 in file /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php on line 57
private $googleMapsApi;
    private $url = 'http://maps.googleapis.com/maps/api/geocode/json?address';
    private $key = 'xxxx';
    private $location;

    public function __construct() 
    {
        $this->googleMapsApi = new Client($this->url, [
            'key' => $this->key,
            'location' => $this->location
        ]);
    }
0 likes
1 reply

Please or to participate in this conversation.