Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tawakkalna-api

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tawakkalna-api

npm package that facilitate calls to TWK APIs and wrap the additional security configurations

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

tawakkalna-api (allow typescript developers Interacting with Tawakkalna’s Endpoint)

Features

  • Simplicity
  • Chained method
  • Zero dependencies
  • Tiny size

Installation

npm install tawakkalna-api

Quickstart

import TawakkalnaApi from "tawakkalna-api";
let result: Record<string, any> = {};
TawakkalnaApi.requestUserFullName()
  .requestUserBloodType()
  .sendAll()
  .then((values) => {
    for (const value of values) {
      if ("data" in value) {
        const json = JSON.parse(value.data as string);

        if (Array.isArray(json)) {
          //handle gallery image or video
          Object.assign(result, json[0]);
        } else if (json.mime_type)
          //handle raw data
          console.log(json.data);
        else {
          Object.assign(result, json); //handle user full name, blood type,...etc
        }
      }
    }
    console.log(result); //{full_name:"الإسم الكامل","blood_type:":1}
  })
  .catch((error) => alert(error));

Here's a breakdown

TawakkalnaApi

The TawakkalnaApi is a wrapper around an HTTP client, providing a chainable methods to make API calls (requests) and handle responses.

Request Chaining

requestUserFullName() and requestUserBloodType() are chained methods for adding Tawakkalna’s endpoints to pending requests list.

Sending Requests

sendAll() Triggers all pending requests sequentially

Handling Responses

  • The then block is executed after all requests are completed.
  • for (const value of values) It iterates over the array of responses values.

Remark Each response object contains a data property if the request was successful.

Keywords

FAQs

Package last updated on 18 Nov 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