From 7966f67569d01c25f7a337962d7d0bb1a0c57808 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Wed, 13 Nov 2024 14:46:59 +0700 Subject: get couries, mapping couries and service --- src/core/api/biteShip.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/api/biteShip.js b/src/core/api/biteShip.js index 9e9e8567..f18421d8 100644 --- a/src/core/api/biteShip.js +++ b/src/core/api/biteShip.js @@ -2,23 +2,27 @@ import axios from 'axios'; const biteShipAPI = async (method, url, body = {}) => { try { - const key = process.env.NEXT_PUBLIC_BITE_SHIP_KEY; - let axiosParameter = { + const key = process.env.NEXT_PUBLIC_BITSEHIP_KEY; + const baseUrl = process.env.NEXT_PUBLIC_BITE_SHIP_HOST; + + const axiosParameter = { method, - url: process.env.NEXT_PUBLIC_BITE_SHIP_HOST + url, - headers: { Authorization: key, 'Content-Type': 'application/json' }, + url: baseUrl + url, + headers: { + Authorization: `Bearer ${key}`, // Tambahkan "Bearer " di depan key + 'Content-Type': 'application/json', + }, + data: body, // Tidak perlu JSON.stringify }; - if (Object.keys(body).length > 0) - axiosParameter.data = JSON.stringify(body); const data = await axios(axiosParameter); - return { success: true, data: data}; + return { success: true, data: data }; } catch (error) { console.log(error); return { success: false, - data : {} + data: {}, }; } }; -- cgit v1.2.3