I imagine this has been posted before but I wasn’t able to find a data object specifically like this one. I’m struggling to understand how extract information from this data object in javascript. It’s a parsed URL.
data = URL {
href: 'http://localhost:8080/test.txt?cat=Mouse',
origin: 'http://localhost:8080',
protocol: 'http:',
username: '',
password: '',
host: 'localhost:8080',
hostname: 'localhost',
port: '8080',
pathname: '/test.txt',
search: '?cat=Mouse',
searchParams: URLSearchParams { 'cat' => 'Mouse' },
hash: ''
}
I can retrieve the URLsearchParams
data.searchParams
, which returns { 'cat' => 'Mouse' }
What is this data structure called: { 'cat' => 'Mouse' }
. I’m confused by the =>
And how do I retrieve the two objects ‘cat’ and ‘Mouse’ separately inside this data structure?
For example, retrieving then setting a variable equal to the first item, ‘cat’ and another variable equal to ‘Mouse’
Thank you