标签: http-toolkit

如何配置在 jest 中运行的 axios 在 POST 之前不发送 OPTIONS?

从 node.js 中,这按预期工作,发送了 POST 响应(正如我使用 httpToolkit 验证的那样)

% node
> const axios = require('axios')
> var r = (async () => { const x = await axios.post('http://example.com/v1/secret/data/foo/bar/baz',{data: {foo: 42}},{headers: {'X-Special-Token': 'DATA'}}); return true;})().then(console.log)
undefined
> true
Run Code Online (Sandbox Code Playgroud)

但是,然后在测试中执行相同的操作jestaxios首先发送 OPTIONS 请求。我正在运行的服务无法处理该问题(不是 example.com)

const axios = require('axios');

describe('Simple Post', () => {
  test('POST', async () => {
    // Axios HERE seems to send an OPTIONS request first...
    const x = await axios.post('http://example.com',
      {data: {foo: 42}},
      {headers: {'X-Special-Token': 'DATA'}});
    expect(x.status).toBe(200); …
Run Code Online (Sandbox Code Playgroud)

jestjs axios http-toolkit

5
推荐指数
1
解决办法
1252
查看次数

如何信任 Android 设备上的证书?

我想设置这个名为 Http Toolkit 的应用程序,但由于某种原因,我收到警告“系统信任已禁用”。我的安卓设备没有root。

https http http-toolkit

4
推荐指数
1
解决办法
9026
查看次数

标签 统计

http-toolkit ×2

axios ×1

http ×1

https ×1

jestjs ×1