>  Q&A  >  본문

Symfony\Component\HttpFoundation\Request::__construct()에 전달된 매개변수 1

다음 오류가 발생했습니다:

SymfonyComponentHttpFoundationRequest::__construct()에 전달된 매개변수 1은 C:xampphtdocssatusehat2appHttpControllersPasienController.php 라인 68에서 호출되는 지정된 배열, 문자열 유형이어야 합니다.

이게 내 기능이야

으아악

68번 라인은

public function curl_postman() {
        $client = new Client();
        $headers = [
          'Content-Type' => 'application/json',
          'Authorization' => 'My Bearer token'
        ];
        $body = '';
        $request = new Request('GET', 'my-api-address', $headers, $body);
        $res = $client->sendAsync($request)->wait();
        echo $res->getBody();
        
    }

P粉378890106P粉378890106210일 전233

모든 응답(1)나는 대답할 것이다

  • P粉124070451

    P粉1240704512024-02-27 10:02:10

    SymfonyComponentHttpFoundationRequest::create() 来代替,它隐式调用请求工厂并返回 Request 개체를 사용할 수 있습니다.

    으아아아

    PS: 명시적으로 지정할 필요가 없습니다. method参数,因为'GET'가 기본값입니다.

    회신하다
    0
  • 취소회신하다