You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@testjg/nativescript-http

Package Overview
Dependencies
Maintainers
1
Versions
5
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

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
2
-80%
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

NativeScript

FAQs

Package last updated on 11 Jun 2025

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