TypeError: Cannot read property Error

Hi Team,
I have created a Scripted API type monitor to check whether file getting download or not. Below is my script.
var assert = require(‘assert’);
$http.head(‘URL’,function(err,res){
assert.ok(res.statusCode==200,‘Expected 200 response but received:’ +res.statusCode);
)};

Daily I am getting twice or thrice this error TypeError:Cannot read property ‘statusCode’ of undefined.
But during this time when I manually checked I am getting 200 response but not sure why it throws error like this even though it had response .Please help me on this or please tell solution to add in my script.

@alakappan18 Realize you have been waiting awhile for a response from our community. This topic category is not monitored by our support team. Hoping that a fellow community member will be able to assist soon! Thanks for your patience.

do we have any solution here?

@Khang.NguyenVinhBui I’m not aware of a solution yet.

@alakappan18 Were you able to resolve on your own?