From f1de27fa1649d05874640d8ddbb6fc41981ce6c3 Mon Sep 17 00:00:00 2001 From: matheusgnreis Date: Mon, 15 Jan 2024 14:16:35 -0300 Subject: [PATCH] chore: update get route --- functions/routes/bling/authentication.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/functions/routes/bling/authentication.js b/functions/routes/bling/authentication.js index e92f5b9..0c0d18c 100644 --- a/functions/routes/bling/authentication.js +++ b/functions/routes/bling/authentication.js @@ -74,9 +74,21 @@ exports.get = ({ appSdk, admin }, req, res) => { return appSdk.getAuth(storeId) .then(async (auth) => { try { - await updateAppData({ appSdk, storeId, auth }, { - code - }) + getAppData({ appSdk, storeId, auth }) + .then(appData => { + const { client_id, client_secret } = appData + console.log('Pass variables', JSON.stringify({client_id, client_secret, code, storeId})) + const bling = new Bling(client_id, client_secret, code, storeId) + bling.preparing + .then((e) => { + console.log('deu certo a criação de autenticação') + res.status(200).redirect('https://app.e-com.plus/#/apps/edit/102418/') + }) + .catch(err => { + console.log(err) + res.status(200).redirect('https://app.e-com.plus/#/apps/edit/102418/') + }) + }) res.status(200).redirect('https://app.e-com.plus/#/apps/edit/102418/') } catch (error) { console.error(error)