Skip to content

Instantly share code, notes, and snippets.

@khobiziilyes
Created January 5, 2025 23:26
Show Gist options
  • Save khobiziilyes/8961fe3903e174438879b3a2b94bba67 to your computer and use it in GitHub Desktop.
Save khobiziilyes/8961fe3903e174438879b3a2b94bba67 to your computer and use it in GitHub Desktop.
type RespObj = {
record_no: string;
create_date_time: string;
eur_buy: string;
eur_sell: string;
usd_buy: string;
usd_sell: string;
cad_buy: string;
cad_sell: string;
gbp_buy: string;
gbp_sell: string;
cny_buy: string;
cny_sell: string;
try_buy: string;
try_sell: string;
chf_buy: string;
chf_sell: string;
sar_buy: string;
sar_sell: string;
aed_buy: string;
aed_sell: string;
tnd_buy: string;
tnd_sell: string;
mad_buy: string;
mad_sell: string;
};
fetch("http://www.forexalgerie.com/connect/updateExchange.php", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: "afous=moh!12!",
})
.then(response => response.json() as Promise<RespObj[]>)
.then(json => json.at(-1)!)
.then(data => {
const { create_date_time, eur_buy, eur_sell, usd_buy, usd_sell } = data;
console.log(`\x1b[34m${create_date_time}\x1b[0m\n`);
console.log(
`EUR (€): \x1b[35m${eur_buy}\x1b[0m / \x1b[32m${eur_sell}\x1b[0m`
);
console.log(
`USD ($): \x1b[35m${usd_buy}\x1b[0m / \x1b[32m${usd_sell}\x1b[0m`
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment