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

katana-client

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

katana-client

A powerful HTTP client module similar to axios

  • 1.0.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

KatanaClient

KatanaClient, Node.js için gelişmiş HTTP ve HTTPS istemci kütüphanesi.

Kurulum

npm install katana-client

Kullanım

const KatanaClient = require('katana-client');

const client = new KatanaClient({
  timeout: 10000,
  maxRedirects: 5,
  followRedirects: true,
  // Diğer seçenekler
});

HTTP İstekleri

client.get('https://api.example.com/data')
  .then(response => {
    console.log('GET response:', response);
  })
  .catch(error => {
    console.error('GET error:', error);
  });

client.post('https://api.example.com/data', { key: 'value' })
  .then(response => {
    console.log('POST response:', response);
  })
  .catch(error => {
    console.error('POST error:', error);
  });

İstek Yönetimi

const req = client.get('https://api.example.com/data');
client.cancelRequest(req);

if (client.isRequestCancelled(req)) {
  console.log('Request was cancelled');
} else {
  console.log('Request is active');
}

client.retryRequest('GET', 'https://api.example.com/data', null, {}, 3)
  .then(response => {
    console.log('Retry successful:', response);
  })
  .catch(error => {
    console.error('Retry failed:', error);
  });

Dosya İşlemleri

client.downloadFile('https://example.com/file.zip', './downloads/file.zip')
  .then(filePath => {
    console.log('File downloaded:', filePath);
  })
  .catch(error => {
    console.error('Download error:', error);
  });

const filePath = './uploads/file.txt';
client.uploadFile('https://api.example.com/upload', filePath)
  .then(response => {
    console.log('File uploaded:', response);
  })
  .catch(error => {
    console.error('Upload error:', error);
  });

Akış İşlemleri

client.streamRequest('https://api.example.com/stream')
  .then(stream => {
    stream.on('data', data => {
      console.log('Stream data:', data);
    });
    stream.on('end', () => {
      console.log('Stream ended');
    });
    stream.on('error', error => {
      console.error('Stream error:', error);
    });
  })
  .catch(error => {
    console.error('Stream request error:', error);
  });

client.retryStreamRequest('https://api.example.com/stream')
  .then(stream => {
    // Akış üzerinde işlem yapma
  })
  .catch(error => {
    console.error('Retry stream request error:', error);
  });

Önbellek ve Sınırlama

client.cacheResponse('https://api.example.com/data', { data: 'cached' }, 60); // 60 saniye boyunca önbelleğe alınır

client.getCacheResponse('https://api.example.com/data')
  .then(response => {
    console.log('Cached response:', response);
  })
  .catch(error => {
    console.error('Cache error:', error);
  });

client.limitRequests('https://api.example.com/rate-limited', 100, 3600)
  .then(() => {
    console.log('Request limit applied successfully');
  })
  .catch(error => {
    console.error('Request limit error:', error);
  });

Keywords

FAQs

Package last updated on 16 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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