阅读(2691) (5)

Laravel 8 请求头

2021-07-05 10:24:27 更新

你可以通过 withHeaders 方法添加请求头。该方法接受一个数组格式的键值对:

$response = Http::withHeaders([
    'X-First' => 'foo',
    'X-Second' => 'bar'
])->post('http://test.com/users', [
    'name' => 'Taylor',
]);