AshYT
AshYT

Reputation: 11

Keep Getting a error object REGEXP isn't a function

I'm using an API to get skins of a ship from a wiki but i keep getting an [object RegExp] is not a function error.

I've tried using Object.values()

title: `Class`,
            description: `${ship.class}`,
            thumbnail: {
                url: `${ship.skins.filter(/Default/)}`,
            },

(node:5532) UnhandledPromiseRejectionWarning: TypeError: [object RegExp] is not a function at Array.forEach (<anonymous>) at Object.run (C:\Users\Ash\Desktop\Discord.js Bot\commands\azurlane\azurship.js:20:36) at process._tickCallback (internal/process/next_tick.js:68:7) (node:5532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:5532) [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.

Upvotes: 0

Views: 101

Answers (1)

Abhishek-Saini
Abhishek-Saini

Reputation: 743

ship.skins.filter(/Default/) //error here [object RegExp] is not a function

you are getting error because filter is a function which take a callback function as its parameter. this callback function accepts 3 parameter : item, index , array

example:

var result = [1,2,3].filter((item,index,array)=> item > 1 );

here, the callback function return true when item is greater then 1, and we have a filtered array as the value of result having value [2,3]

Upvotes: 1

Related Questions