Skip to content

Instantly share code, notes, and snippets.

@mornir
Created March 14, 2018 20:50
Show Gist options
  • Save mornir/aa2ce0b156d9d10b116749ac83cfc744 to your computer and use it in GitHub Desktop.
Save mornir/aa2ce0b156d9d10b116749ac83cfc744 to your computer and use it in GitHub Desktop.
Passing parameters to fetch when making fetch requests
const params = { a: 'foo', b: 'bar' };
const urlParams = new URLSearchParams(Object.entries(params));
fetch('/some/url?' + urlParams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment