Parse URL Query
NodeJS
Medium
3 views
Problem Description
Parse ?q=react&page=2 from a URL and print an object.
Output Format
Print JSON.
Constraints
Use URL and URLSearchParams.
Official Solution
const u = new URL('http://meetcode.local/search?q=react&page=2');
const out = Object.fromEntries(u.searchParams.entries());
console.log(JSON.stringify(out));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!