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

@payload-enchants/sdk

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@payload-enchants/sdk

## Install

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Typescript-Safe Payload API Client

Install

pnpm add @payload-enchants/sdk

Usage

import { PayloadApiClient } from '@payload-enchants/sdk';

// Import it from generated types
import { Config } from 'payload-types';

const client = new PayloadApiClient<Config>({
  apiURL: 'http://localhost:3000/api',
});

// The syntax is the same as in the Local API, except for `updateById` and `deleteById` (additional operations)
const data = await client.find({ collection: 'pages' });

To rewrite headers, you can pass your fetcher

const client = new PayloadApiClient<Config>({
  apiURL: '',
  fetcher: (url, init) => {
    return fetch(url, {
      ...(init ?? {}),
      headers: {
        ...(init?.headers ?? {}),
        Authorization: 'API-Key users some-api-key',
      },
    });
  },
});

Fields selection

This package provides integratation with @payload-enchants/fields-select plugin

const { docs } = await client.find({ collection: 'pages', select: ['id', 'createdAt'] });

docs[0].createdAt; // ok
docs[0].id; // ok
docs[0].updatedAt; // err, Property 'updatedAt' does not exist on type 'Pick<Page, "id" | "createdAt">'

FAQs

Package last updated on 16 Jul 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