-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
By default browser-request is async but I don't see any obvious way to make it sync. I have two functions, getHTTP
and HTTPExists
, but I also want to make getHTTPSync
and HTTPExistsSync
.
What are my options to make them sync?
function HTTPExists(url, cb) {
request({ url: resolve(url), method: 'HEAD' }, function(err, res) {
if (err) return cb(null, false);
cb(null, /4\d\d/.test(res.statusCode) === false);
});
}
function getHTTP(url, cb) {
request(resolve(url), function (error, response, body) {
if (!error && response.statusCode == 200) {
cb(null, body);
} else {
cb(error, body)
}
})
}
nadavye
Metadata
Metadata
Assignees
Labels
No labels