Skip to content

Instantly share code, notes, and snippets.

@reallabs
Created October 18, 2019 00:35
Show Gist options
  • Save reallabs/c54891e77a7c5fa2df291eeacea352d8 to your computer and use it in GitHub Desktop.
Save reallabs/c54891e77a7c5fa2df291eeacea352d8 to your computer and use it in GitHub Desktop.
Adjust Cost API not working
const fetch = require("node-fetch");
let clickId = 111450850;
winston.info("Trying to send cost data to adjust for click_id: " + clickId);
let data = {
cost_type: "cpi",
cost_currency: "usd",
cost_amount: "1.72",
cost_id: "jetfuel_" + clickId,
tag: "jetfuel"
};
let urlParameters = Object.entries(data).map(e => e.join('=')).join('&');
let args = {
method: 'POST',
body: urlParameters,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
const response = await fetch("https://app.adjust.com/cost", args);
if (response.status !== 200) {
winston.error("Got a FAILED response (" + JSON.stringify(response) + "from adjust when we tried to send cost for click_id: " + clickId);
} else {
winston.info("Got a SUCCESS response from adjust when we tried to send cost for click_id: " + clickId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment