File Example
const axios = require("axios");
const fs = require("fs");
const testFile = async () => {
try {
const branchId = "";
const apiKey = "";
const path = "";
const buffer = fs.readFileSync(path);
const res = await axios.post(
`https://api.slipok.com/api/line/apikey/${branchId}`,
{
files: buffer,
log: true,
// amount: number, // Add this to check with amount of the slip
},
{
headers: {
"x-authorization": apiKey,
"Content-Type": "multipart/form-data",
},
}
);
// Handle success slip
const slipData = res.data.data;
console.log(slipData);
} catch (err) {
// Handle invalid slip
if (axios.isAxiosError(err)) {
const errorData = err.response.data;
console.log(errorData.code); // Check error code
console.log(errorData.message); // Check error message
return;
}
console.log(err);
}
};
testFile();
Data Example
const axios = require("axios");
const testData = async () => {
try {
const branchId = "";
const apiKey = "";
const qrString = "";
const res = await axios.post(
`https://api.slipok.com/api/line/apikey/${branchId}`,
{
data: qrString,
log: true,
// amount: number, // Add this to check with amount of the slip
},
{
headers: {
"x-authorization": apiKey,
},
}
);
// Handle success slip
const slipData = res.data.data;
console.log(slipData);
} catch (err) {
// Handle invalid slip
if (axios.isAxiosError(err)) {
const errorData = err.response.data;
console.log(errorData.code); // Check error code
console.log(errorData.message); // Check error message
return;
}
console.log(err);
}
};
testData();
Url Example
const axios = require("axios");
const testUrl = async () => {
try {
const branchId = "";
const apiKey = "";
const url = "";
const res = await axios.post(
`https://api.slipok.com/api/line/apikey/${branchId}`,
{
url,
log: true,
// amount: number, // Add this to check with amount of the slip
},
{
headers: {
"x-authorization": apiKey,
},
}
);
// Handle success slip
const slipData = res.data.data;
console.log(slipData);
} catch (err) {
// Handle invalid slip
if (axios.isAxiosError(err)) {
const errorData = err.response.data;
console.log(errorData.code); // Check error code
console.log(errorData.message); // Check error message
return;
}
console.log(err);
}
};
testUrl();