Skip to content

Instantly share code, notes, and snippets.

@IngIeoAndSpare
Last active March 6, 2019 02:36
Show Gist options
  • Save IngIeoAndSpare/fde568bb9c93d2d8f418be778e505079 to your computer and use it in GitHub Desktop.
Save IngIeoAndSpare/fde568bb9c93d2d8f418be778e505079 to your computer and use it in GitHub Desktop.
just study code. url file health checker.
// it just study code...
const axios = require('axios');
module.exports = {
/**
* check url file health. if request return 40X code, then chacker return false.
* @param {string} targetUrl target url string
* @param {object} headerInfo header info
* @returns {object} return object {result : (boolean)fileHealth, info : (object)headerInfo}
*/
checkerFile : function (targetUrl, headerInfo) {
let resultInfo = {
result : false,
info : null
};
axios.head(targetUrl, {
headers : header
}).then(response => {
resultInfo.result = true;
resultInfo.info = response;
return resultInfo;
}).catch(err => {
resultInfo.info = err;
return resultInfo;
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment