npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@commite/ajax-client

v0.3.2

Published

Observable based HTTP client on top of rxjs/ajax for browser and node.js.

Downloads

27

Readme

Ajax Client

Build Status Codacy Badge Codacy Badge

Observable based HTTP client on top of rxjs/ajax for browser and node.js.

Table of contents

Installation

npm i --save @commite/ajax-client rxjs

Dependencies

"rxjs": "^6.3.3"

API

Ajax client uses rxjs/ajax API to perform calls and returns rxjs/observable.

All request accepts an Ajax request options, post, put and patch requests body param can also be typed, other way any type will be assumed.

All request returns an Ajax response, response param can also be typed, other way any type will be assumed.

Config

A base url can be setted using library constructor.

const ajaxClient = new AjaxClient({
  baseUrl: 'my-base-url.com'
});

Equivalent to adding an interceptor like:

interceptors.request.push(request => ({
  ...request,
  url: `${baseUrl}${request.url}`
}));

Get/Delete

[get|delete]<T>(url: string, options?: Partial<AjaxClientRequest<null>>): Observable<AjaxClientResponse<T>>

Get example

const ajaxClient = new AjaxClient();

ajaxClient.get<GetUsersResponse>('/users', { headers: ... }).subscribe((userRes) => {
  [...]
});

Back to top

Post/Put/Patch

[post|put|patch]<T, Y>(url: string, body: Y, options?: Partial<AjaxClientRequest<Y>): Observable<AjaxClientResponse<T>>

Post example

const ajaxClient = new AjaxClient();

ajaxClient.post<PostUserResponse, PostUserBody>('/users', { email: '[email protected]'}, { headers: ... }).subscribe((userRes) => {
  [...]
});

Back to top

Request

request<T, Y>(options: Partial<AjaxClientRequest<Y>>): Observable<AjaxClientResponse<T>>

Request example

ajaxClient.request<RequestResponse, RequestBody>({
  method: 'POST',
  body: {...},
  headers: {...}
}).subscribe((reqRes) => {
  [...]
})

Back to top

Interceptors

Request and response could be intercepted.

Request interceptor

A request interceptor is a function that accepts a Partial<AjaxClientRequest<any>> object and returns a modified (or not) Partial<AjaxClientRequest<any>>.

RequestInterceptor = (
  options: Partial<AjaxRequest<any>>
) => Partial<AjaxRequest<any>>

Request interceptors can be managed through ajaxClient.interceptors.request array.

ajaxClient.interceptors.request.push(options => {
  return {
    ...options,
    url: `https://my-base-url.com/${options.url}`
  };
});

Response interceptor

A response interceptor is a function that accepts a AjaxClientResponse<any> object and returns a modified (or not) AjaxClientResponse<any>.

ResponseInterceptor = (response: AjaxClientResponse<any>) => AjaxClientResponse<any>;

Response interceptors can be managed through ajaxClient.interceptors.response array.

ajaxClient.interceptors.response.push(ajaxResponse => {
  return {
    ...ajaxResponse,
    response: ajaxResponse.response.split(',')
  };
});

Back to top

TypeScript

Ajax client is coded entirely in TypeScript with target:'es5'.

Building/Testing

  • npm install
  • npm run build
  • npm run lint
  • npm run test or npm run test:watch

Contributing

License

Copyright (c) 2018 Commite Inc under LGPLv3 license.