Google-images search module gives deprecated warning

I am trying to make a search with google search api using google-images module but its giving the following warnings and I don’t know how to get rid of them.

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): HTTPError: Response code 403 (Forbidden)

DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

var app = express();
const GoogleImages = require('google-images');
 
const client = new GoogleImages('CSE ID', 'API KEY');
 


app.get("/", function (request, response) {

client.search('Steve Angello')
    .then(images => {
      response.end(images[0].url);
       
    });

}); //end of get


You need to handle the promise’s rejection. You can place a catch method after your then.

client.search('Steve Angello')
    .then(images => {
      response.end(images[0].url);   
    })
    .catch(error => {
        // handle error
    })

Thank you for your reply! I tried that too but does not work.
Later today I found out that google image search is depreciated

Yes, that’s why the request is failing, but that’s not what the deprecation warning means. The 403 response is causing an error which isn’t handled.