mercredi 1 avril 2020

Class 'App\Http\Controllers\Auth\GuzzleHttp\RequestOptions' not found

I have a simple registration form I would like to send post data to external service using guzzle

Here is what I have so far in the register controller

 protected function create(array $data)
    {
        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            ]);

        $client = new Client();
        $response = $client->post('app.salesmanago.pl/api/contact/insert', [
            GuzzleHttp\RequestOptions::JSON => [        
            'allow_redirects' => true,
            'timeout' => 2000,
            'http_errors' => true,
            'headers' => [
                'Accept' => 'application/json, application/json',
                'Content-Type' => 'application/json',
                'clientId' => 'mykey',
                'apiKey' => 'mykey',

            ],
            'form_params' => [
                'name' => $data['name'],
                'email' => $data['email'],
            ]

          ]
        ]);


    dd($response);

        return $user;
    }

Now when I fill the form and send the form data I get the following error

Class 'App\Http\Controllers\Auth\GuzzleHttp\RequestOptions' not found

Note I have installed guzzle like this: composer require guzzlehttp/guzzle:~6.0

What am I doing wrong here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire