I have string:
city = 'Hải Phòng'
and an array that I get from an API which looks like this:
data = [{},{},{},{ MaTinhThanh: 'xx', TenTinhThanh: 'Hải Phòng' },{},{}]
I want to find an object in my data:
mycity = data.find( c=>c.TenTinhThanh.includes(city))
the above gives undefined
, but I expect
{ MaTinhThanh: 'xx', TenTinhThanh: 'Hải Phòng' }
My API endpoint is:
https://donhang.vnpost.vn/api/api/TinhThanh/GetAll
I am using visual code, Axios, nodejs
I also tried the getting the length of both strings:
data[3].TenTinhThanh.length` ====>11
city.length` ====>9
What is the problem?