const superagent = require('superagent');
const crypto = require('crypto');
const serverConfig = {
protocol: 'https:',
hostname: 'translate.rozetta-api.io',
port: 443
};
const authConfig = {
accessKey: 'ACCESS_KEY',
secretKey: 'SECRET_KEY',
nonce: Date.now().toString()
};
const sendRequest = (serverConfig, authConfig) => {
const url = '/api/v1/dictionary/dictionary-all';
const signature = authUtils.generateSignature(
url,
authConfig.secretKey,
authConfig.nonce
);
const headers = {
accessKey: authConfig.accessKey,
signature,
nonce: authConfig.nonce,
};
return superagent.delete(`${serverConfig.protocol}//${serverConfig.hostname}${url}`)
.set(headers)
.then((res) => {
return res.body;
}).catch((err) => {
return err.message;
});
};
const main = async () => {
try {
const response = await sendRequest(serverConfig, authConfig);
console.log('Server response:');
console.log(response);
} catch (error) {
console.error(error);
}
};
main();