Skip to content

Use URL.searchParams #10

@wagenaartje

Description

@wagenaartje

Once URL.searchParams has compability with more browsers, we can use this to simplify the _createURL function. At this moment, the function is supported by:

  • Chrome ^51.0
  • Firefox ^52.0
  • Node ^7.5.0

The usage is pretty simple, example:

var url = new URL('https://www.alphavantage.co/query?');
var params = {
  function: 'TIME_SERIES_INTRADAY',
  symbol: 'MSFT',
  interval: '1min',
  apikey: 'demo'  
};

Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))

For Node, all you need to do is add:

var URL = require('url').URL;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions