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

@testjg/nativescript-http

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testjg/nativescript-http

Add a plugin description

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

@testjg/nativescript-http

npm version

Http helper lib. Under the hood it uses okhttp (v3) for Android and NSURLSession for iOS.

Has peer dependencies on url-join and rxjs.

Installation

ns plugin add @testjg/nativescript-http

Usage

import { createHttp, forRelativeUrl } from '@testjg/nativescript-http';
import { firstValueFrom } from 'rxjs';
import { catchError, switchMap } from 'rxjs/operators';

export class TodosService {
  http = createHttp('https://jsonplaceholder.typicode.com');
  todos = forRelativeUrl('todos', this.http);

  fetchTodo(id: number) {
    const json$ = this.todos
      .request({
        method: 'GET',
        url: `${id}`,
        headers: { 'Accept-Language': ['ca', 'en'] },
      })
      .pipe(
        switchMap((res) => res.json()),
        catchError((error) => null)
      );

    return firstValueFrom(json$);
  }
}

Pro tip: Use functions like jsonBody or multiPartBody to create the appropiate request content.

License

Apache License Version 2.0

Keywords

FAQs

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