New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@truefusion/somnia

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

@truefusion/somnia

Beautifully RESTful.

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

somnia

Beautifully RESTful.

Installation

npm install @truefusion/somnia --save

API

Basic syntax: somnia(URL, OPTIONS).METHOD(DATA, OPTIONS): Promise

METHOD: HTTP verb.
OPTIONS: fetch options.

Examples

import somnia from 'somnia';

var blog = somnia('/blog');

/* /blog/posts */
var posts = blog('posts');
posts.post({
    title: 'somnia',
});

/* /blog/posts?category=javascript */
posts.get({
    category: 'javascript',
});

/* /blog/posts/1 */
var firstPost = posts(1);
firstPost.get();
firstPost.put({ title: 'somnia is simple' });
firstPost.patch({ title: 'somnia is really simple' });
firstPost.delete();

var firstPostComments = firstPost('1/comments');

/* /blog/posts/1/comments */
firstPostComments.get();

/* /blog/posts/1/comments/1 */
firstPostComments(1).get();

Easily converts to string:

String(somnia('/blog/posts')) // "/blog/posts"

To catch errors:

somnia('/posts')
  .get()
  .catch(function({ statusText }) {
    console.log(statusText);
});

Options are inherited:

var posts = somnia('/blog/posts', fetchOptions);
var comments = posts('1/comments'); // Will inherit fetchOptions

Provide your own drop-in replacement for fetch:

import fetch from 'node-fetch';

var blog = somnia('/blog', { fetch });

Keywords

fetch

FAQs

Package last updated on 12 Oct 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