Last active
March 6, 2019 02:36
-
-
Save IngIeoAndSpare/fde568bb9c93d2d8f418be778e505079 to your computer and use it in GitHub Desktop.
just study code. url file health checker.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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