mSet method Null safety

  1. @JS('set')
Object mSet(
  1. String name,
  2. String value

Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist. myHeaders.set(name, value); Creating an empty Headers object is simple:

var myHeaders = new Headers(); // Currently empty

You could add a header to this using Headers.append, then set a new value for this header using set():

myHeaders.append('Content-Type', 'image/jpeg'); myHeaders.set('Content-Type', 'text/html'); If the specified header does not already exist, set() will create it and set its value to the specified value. If the specified header does already exist and does accept multiple values, set() will overwrite the existing value with the new one:

myHeaders.set('Accept-Encoding', 'deflate'); myHeaders.set('Accept-Encoding', 'gzip'); myHeaders.get('Accept-Encoding'); // Returns 'gzip'

You'd need Headers.append to append the new value onto the values, not overwrite it.


external Object mSet(String name, String value);