-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintapi-lib.js
More file actions
28 lines (23 loc) · 770 Bytes
/
Copy pathintapi-lib.js
File metadata and controls
28 lines (23 loc) · 770 Bytes
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
const axios = require('axios')
class Intapi {
constructor(apiBaseUrl){
this.apiBaseUrl = apiBaseUrl;
}
async getRequest(endpoint, params = {}){
try{
const response = await axios.get(`${this.apiBaseUrl}/${endpoint}`, { params });
return response.data;
} catch(error){
throw new Error(`Error making GET request to ${endpoint}:${error.message}`);
}
}
async postRequest(endpoint, data = {}){
try{
const response = await axios.post(`${this.apiBaseUrl}/${endpoint}`, data);
return response.data;
} catch(error){
throw new Error(`Error making POST request to ${endpoint}:${error.message}`);
}
}
}
module.exports= Intapi;