0
Hello, Currently I have an application that Backend is in PHP and consumes a JSON API. Through the query I can save the data in my Mysql DB. I want to know if it is possible to do this in Javascript.
Follow an example of the code I have;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Cache;
class BlingClient {
protected $apikey, $guzzle, $url;
public function __construct($apikey)
{
$this->apikey = env('BLING_APIKEY');
$this->guzzle = new Client();
$this->url = env('BLING_URL', 'https://bling.com.br/Api/v2/');
}
public function filters($arr_filters = [])
{
$filters = [];
foreach($arr_filters as $k => $arr)
{
$filters[] = $k.'[' . $arr . ']';
}
$filters = implode(";", $filters);
return $filters;
}
public function getPedidos($arr_filters = [], $page = 1)
{
$filters = $this->filters($arr_filters);
$res = $this->guzzle->request('GET', $this->url . 'pedidos/page=' . $page . '/json/', [
'query' => [
'apikey' => $this->apikey,
'filters' => $filters
]
]);
$pedidos = json_decode($res->getBody());
return (!isset($pedidos->retorno->erros))? $pedidos->retorno->pedidos : [];
}
By way of learning, I want to know if it is possible to do this.
You want to know if you can do this in the backend with Node?
– Costamilam
Yeah, there you go. Today my backend is being Laravel and I read some articles saying that Nosql is more scalable, hence my doubt on whether it is possible to do this and if yes, how?
– Aguinaldo Tupy
Yes, you can, but it’s worth redoing your whole system because of scalability?
– Costamilam
@Costamilam, I won’t redo it, it’s more for learning title.
– Aguinaldo Tupy