UNPKG

esnekpos

Version:

Node.js entegrasyon paketi - EsnekPOS ödeme sistemi için resmi olmayan istemci

40 lines (34 loc) 953 B
/** * HTTP istek yardımcı fonksiyonları */ const axios = require('axios'); const { handleApiError } = require('./response'); /** * API'ye istek gönderir * @param {Object} options - İstek seçenekleri * @param {string} options.baseUrl - API temel URL'i * @param {string} options.endpoint - API endpoint'i * @param {Object} options.data - İstek gövdesi * @param {Object} [options.headers] - İstek başlıkları * @returns {Promise<Object>} - API yanıtı */ async function makeRequest(options) { try { const { baseUrl, endpoint, data, headers = {} } = options; const response = await axios({ method: 'POST', url: `${baseUrl}${endpoint}`, data, headers: { 'Content-Type': 'application/json', ...headers } }); return response.data; } catch (error) { throw handleApiError(error); } } module.exports = { makeRequest };