jsonp method

Future<void> jsonp(
  1. Object value, {
  2. String callbackName = 'callback',
  3. MediaType? contentType,
})

Returns a JSONP response.

You can override the contentType sent; by default it is application/javascript.

Implementation

Future<void> jsonp(
  Object value, {
  String callbackName = 'callback',
  MediaType? contentType,
}) {
  if (!isOpen) throw closed();
  this.contentType = contentType ?? MediaType('application', 'javascript');
  write('$callbackName(${serializer(value)})');
  return close();
}