summaryrefslogtreecommitdiff
path: root/src/core/api/biteShip.js
blob: f18421d8999a035ae2153f568d0e6426ecd15172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import axios from 'axios';

const biteShipAPI = async (method, url, body = {}) => {
  try {
    const key = process.env.NEXT_PUBLIC_BITSEHIP_KEY;
    const baseUrl = process.env.NEXT_PUBLIC_BITE_SHIP_HOST;

    const axiosParameter = {
      method,
      url: baseUrl + url,
      headers: {
        Authorization: `Bearer ${key}`, // Tambahkan "Bearer " di depan key
        'Content-Type': 'application/json',
      },
      data: body, // Tidak perlu JSON.stringify
    };

    const data = await axios(axiosParameter);

    return { success: true, data: data };
  } catch (error) {
    console.log(error);
    return {
      success: false,
      data: {},
    };
  }
};

export default biteShipAPI;