Reputation: 207
i tried to call localhost API in my application using guzzle, but i got this error:
ServerException in RequestException.php line 111:
Server error: `GET http://localhost/WingsFeedAPI/public/products` resulted
in a `500 Internal Server Error` response:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="robots" content="noindex,nofollow (truncated...)
the API made with https://github.com/ellipsesynergie/api-response, and when i access http://localhost/WingsFeedAPI/public/products it returns :
// 20170517054157
// http://localhost/WingsFeedAPI/public/products
{
"data": [
{
"id": 1,
"nama_barang": "Daging ayam",
"harga_barang": "5000",
"rating": "123",
"jenis_barang": "daging",
"expired": "2017-05-03"
}
]
}
And this is how i call that API in my application
Controller :
public function index()
{
$client = new \GuzzleHttp\Client();
$res = $client->request('GET','http://localhost/WingsFeedAPI/public/products');
echo $res->getBody();
}
Route :
Route::get('/', 'WelcomeController@index');
Upvotes: 1
Views: 7825
Reputation: 207
I got the solution from here; it requires the following steps;
The first one: to remove section below from the .env
file,
DB_CONNECTION=mysql
DB_HOST=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
The second one, to define in the config/database.php
file the MySQL database parameters.
The snippet below highlights the portion to be edited for the database configuration a referred right above;
'mysql' => [
'driver' => 'mysql',
'host' => '',
'database' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Upvotes: 3