Initial commit

This commit is contained in:
meusinfirmary
2025-04-22 14:31:37 +07:00
commit b7e852126c
115 changed files with 23188 additions and 0 deletions

50
test.js Normal file
View File

@ -0,0 +1,50 @@
const axios = require('axios').default;
const url = require('url');
const request = require('./config/request');
// const makeRequest = require('request');
// using axios
(async () => {
let params = new url.URLSearchParams({
lat: -6.70982,
lon: 106.99451555555557,
format: 'geojson',
});
const axInstance = axios.create();
axios.defaults.timeout = 3000;
axios.defaults.crossDomain = true;
// respReverseGeo = await axios({
// url: request.osm_reverse_geo.urlFull,
// method: request.osm_reverse_geo.method,
// params: params,
// timeout: 3000,
// responseType: 'json',
// });
console.log('RUNNING');
let respReverseGeo = await axInstance.get(request.osm_reverse_geo.urlFull + '?' + params.toString(), {
timeout: 3000,
});
console.log(respReverseGeo.data);
console.log('SUCCESS');
});
// using standard http library
(async () => {
makeRequest('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY', { json: true }, (err, res, body) => {
if (err) { return console.log(err); }
console.log(body.url);
console.log(body.explanation);
});
});
(async () => {
/**
* fix DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains
* because of string CawangPluit
* solution: https://stackoverflow.com/questions/23223718/failed-to-execute-btoa-on-window-the-string-to-be-encoded-contains-characte
* window.btoa( unescape(encodeURIComponent(str) ) is deprecated => window.btoa(encodeURIComponent(str))
*/
console.log(encodeURIComponent('CawangPluit'));
console.log(typeof null);
console.log(typeof encodeURIComponent(null));
})();