0

here is my controller code:

public function tournaments() {
        $data = 0;
        $response = Http::withHeaders(
            [
                'x-rapidapi-host'=> 'uxxxx',
                'x-rapidapi-key'=> 'asdfasdfas',
            ]
    )->get('https://unibet.p.rapidapi.com/competitions-by-sport/football');
return $response;
}

and response message received: {"message":"Missing required parameters"}

How can i add parameters to these code? for exmpl: params: {sport: 'football'},

And maybe someone could share a tutorial video on how to work with the API LARAVEL?

2
  • 1
    You shouldn't post your api key on Stack overflow, you should mask it Commented Jan 15, 2022 at 12:54
  • 1
    you should get a new key now, the edit history for this post is publicly visible Commented Jan 15, 2022 at 13:59

1 Answer 1

1

If you're talking about query parameters, that's what you're looking for: https://laravel.com/docs/8.x/http-client#get-request-query-parameters

When making GET requests, you may either append a query string to the URL directly or pass an array of key / value pairs as the second argument to the get method

Here's an example of what it would look like:

public function tournaments() {
    $data = 0;
    $response = Http::withHeaders(
        [
            'x-rapidapi-host'=> 'uxxxx',
            'x-rapidapi-key'=> 'asdfasdfas',
        ]
    )->get('https://unibet.p.rapidapi.com/competitions-by-sport', [
        'sport' => 'football'
    ]);
    return $response;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.