2 回答

TA貢獻1772條經(jīng)驗 獲得超8個贊
您正在嘗試在名為 error 的字符串中搜索“registered”,但沒有嘗試這樣做:
message = 'User error fabric-ca request register failed with errors [[{"code":0,"message":"Registration of \'yandgsub15\' failed: Identity \'yandgsub15\' is already registered"}]]' }
var n = message.includes("registered");

TA貢獻1798條經(jīng)驗 獲得超3個贊
我認(rèn)為您只是不搜索好的變量
在您的示例中,您正在嘗試搜索"registered"而error不是message
下面的代碼正在工作
message = 'User error fabric-ca request register failed with errors [[{"code":0,"message":"Registration of \'yandgsub15\' failed: Identity \'yandgsub15\' is already registered"}]]'
var n = message.includes('registered')
console.log(n) // true
添加回答
舉報