Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ky

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ky - npm Package Compare versions

Comparing version 0.29.0 to 0.30.0

7

distribution/core/Ky.js

@@ -10,3 +10,3 @@ import { HTTPError } from '../errors/HTTPError.js';

constructor(input, options = {}) {
var _a, _b;
var _a, _b, _c;
this._retryCount = 0;

@@ -72,3 +72,3 @@ this._input = input;

this._options.body = JSON.stringify(this._options.json);
this.request.headers.set('content-type', 'application/json');
this.request.headers.set('content-type', (_c = this._options.headers.get('content-type')) !== null && _c !== void 0 ? _c : 'application/json');
this.request = new globalThis.Request(this.request, { body: this._options.body });

@@ -122,3 +122,4 @@ }

ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);
const response = (await result).clone();
const awaitedResult = await result;
const response = awaitedResult.clone();
if (type === 'json') {

@@ -125,0 +126,0 @@ if (response.status === 204) {

@@ -205,2 +205,3 @@ import type { LiteralUnion, Required } from './common.js';

export declare type InternalOptions = Required<Omit<Options, 'hooks' | 'retry'>, 'credentials' | 'fetch' | 'prefixUrl' | 'timeout'> & {
headers: Required<Headers>;
hooks: Required<Hooks>;

@@ -220,2 +221,2 @@ retry: Required<RetryOptions>;

}
export { RetryOptions };
export type { RetryOptions } from './retry.js';

@@ -10,3 +10,2 @@ import { TimeoutError } from '../errors/TimeoutError.js';

}, options.timeout);
/* eslint-disable promise/prefer-await-to-then */
void options

@@ -19,3 +18,2 @@ .fetch(request)

});
/* eslint-enable promise/prefer-await-to-then */
});

@@ -22,0 +20,0 @@ export const delay = async (ms) => new Promise(resolve => {

{
"name": "ky",
"version": "0.29.0",
"version": "0.30.0",
"description": "Tiny and elegant HTTP client based on the browser Fetch API",

@@ -70,7 +70,7 @@ "license": "MIT",

"pify": "^5.0.0",
"playwright-chromium": "^1.16.3",
"raw-body": "^2.4.1",
"ts-node": "^10.4.0",
"typescript": "^4.4.4",
"xo": "^0.45.0"
"playwright-chromium": "^1.19.2",
"raw-body": "^2.5.1",
"ts-node": "^10.6.0",
"typescript": "~4.6.2",
"xo": "^0.48.0"
},

@@ -77,0 +77,0 @@ "sideEffects": false,

@@ -528,2 +528,22 @@ <div align="center">

### Setting a custom `Content-Type`
Ky automatically sets an appropriate [`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) header for each request based on the data in the request body. However, some APIs require custom, non-standard content types, such as `application/x-amz-json-1.1`. Using the `headers` option, you can manually override the content type.
```js
import ky from 'ky';
const json = await ky.post('https://example.com', {
headers: {
'content-type': 'application/json'
}
json: {
foo: true
},
}).json();
console.log(json);
//=> `{data: '🦄'}`
```
### Cancellation

@@ -530,0 +550,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc