New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ardatan/sync-fetch

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ardatan/sync-fetch

Synchronous version of the Fetch API

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @ardatan/sync-fetch?

@ardatan/sync-fetch is an npm package that provides a synchronous version of the fetch API. This can be particularly useful in environments where asynchronous operations are not feasible or desired, such as in certain testing scenarios or when working with legacy codebases.

What are @ardatan/sync-fetch's main functionalities?

Synchronous HTTP GET Request

This feature allows you to perform a synchronous HTTP GET request. The code sample demonstrates fetching a post from a placeholder API and logging the response data.

const fetch = require('@ardatan/sync-fetch');
const response = fetch('https://jsonplaceholder.typicode.com/posts/1');
const data = response.json();
console.log(data);

Synchronous HTTP POST Request

This feature allows you to perform a synchronous HTTP POST request. The code sample demonstrates sending a POST request to a placeholder API with a JSON payload and logging the response data.

const fetch = require('@ardatan/sync-fetch');
const response = fetch('https://jsonplaceholder.typicode.com/posts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ title: 'foo', body: 'bar', userId: 1 })
});
const data = response.json();
console.log(data);

Handling HTTP Headers

This feature allows you to include HTTP headers in your synchronous fetch requests. The code sample demonstrates fetching a post with an Authorization header.

const fetch = require('@ardatan/sync-fetch');
const response = fetch('https://jsonplaceholder.typicode.com/posts/1', {
  headers: {
    'Authorization': 'Bearer token'
  }
});
const data = response.json();
console.log(data);

Other packages similar to @ardatan/sync-fetch

Keywords

FAQs

Package last updated on 22 Jun 2022

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