Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const keepSession = () =>
axios.head(window.location.href).then(() => resetTimeout());
new Promise(resolve =>
axios
.head(url)
.then(() =>
axios
.get(url, { responseType: "stream" })
.then(({ data }) =>
data.pipe(createWriteStream(path.join(imagePath, `${id}.jpg`)))
)
.then(() => {
resolve(url)
})
.catch(e => {
resolve(false)
})
)
.catch(() => {
resolve(false)
public head(url: string, config?: HttpClientRequestConfig): Observable> {
return from(axios.head(url, config));
}
const fetch = (url, options) => {
const { method = 'get', data } = options
switch (method.toLowerCase()) {
case 'get':
return axios.get(url, { params: data })
case 'delete':
return axios.delete(url, { data })
case 'head':
return axios.head(url, data)
case 'post':
return axios.post(url, stringify(data))
case 'put':
return axios.put(url, stringify(data))
case 'patch':
return axios.patch(url, data)
default:
return axios(options)
}
}
public assetExists = async (assetName): Promise => {
try {
const response = await axios.head(this.getAssetFullPath(assetName))
return response.status === 200;
} catch (error) {
winston.error(`Error checking file ${this.getAssetFullPath(assetName)} existence on S3`)
return false
}
}
static head>(
url: string,
config?: AxiosRequestConfig,
): Promise {
return axios.head(url, config);
}
async function checkRemote(url) {
if (checkRemotePages) {
try {
await axios.head(url);
} catch (err) {
if (err.message.indexOf('404') >= 0) {
return 'Not found';
} else if (err.message.indexOf('409') < 0) {
return err.message;
}
}
}
}
const fetch = (url, options) => {
const { method = 'get', data } = options
switch (method.toLowerCase()) {
case 'get':
return axios.get(url, { params: data })
case 'delete':
return axios.delete(url, { data })
case 'head':
return axios.head(url, data)
case 'post':
return axios.post(url, data)
case 'put':
return axios.put(url, data)
case 'patch':
return axios.patch(url, data)
default:
return axios(options)
}
}