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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cajaxjs

v3.0.7

Published

CajaxJS is an lightweight JS Http client for everyone! (Promise support)

Downloads

30

Readme

CAJAX (ClassedAjax) 3.0.6 client for everyone!

NPM

npm install cajaxjs

CDN

<script src="https://cdn.jsdelivr.net/npm/cajaxjs@x/dist/cajax.js"></script>
<!-- OR -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cajax.js"></script>

CDN (module, works for Deno too)

test.js

import { Cajax } from 'https://cdn.jsdelivr.net/npm/[email protected]/index.js'

new Cajax()
    .get("https://interaapps.de")
    .then(async (res) => {
        console.log(await res.text())
    })

Example Usage


import { Cajax, CajaxRequest, CajaxResponse, FetchRequestProvider } from 'https://cdn.jsdelivr.net/npm/[email protected]/index.js'

const client = new Cajax()

// There are currently two RequestProvider. Cajax automaticly selects the best one for the user
client.requestProvider = new FetchRequestProvider()

// Await needs to be in a async scope
const response = await client.get("https://interaapps.de")
const responseText = await response.text();
console.log(responseText)

// Using query parameters
client.get("https://interaapps.de", {
    hello: "world"
})
    .then(res=>res.text())
    .then(res=>{
        console.log("Hello world")
    })

// Adding headers
client.get("https://interaapps.de", {
    hello: "world"
}, {
    headers: {
        hello: "World (But this is a header)"
    }
})

// Posting. The second parameter is the data
client.post("https://interaapps.de", {
    hello: "world"
})

// File Upload
const formData = new FormData()
formData.append("file", document.getElementById("input").files[0])
client.post("/upload", formData)
    .then(res=>{
        // ...
    })

// onDownloadProgress (Not supportet for FetchRequestProvider, use XHRHttpRequestProvider)
client.get("https://interaapps.de", {
    hello: "world"
}, {
    onDownloadProgress(event){
        console.log(event.loaded+' of '+event.total)
    }
})

options

/*
    You can either set your options into the third parameter of a request or just set it for the whole client
*/

const client = new Cajax("https://interaapps.de/base_url", {
    headers: {
        hello: "World"
    },

    // Might be interesting for PHP-Developers
    contentType: "application/x-www-form-urlencoded"
})

// Or you can set it here
client.setHeader("hello", "world")

// Helper
client.bearer("KEY")

// You are always converting data to json or check it before using it? Then you can use promiseInterceptor
// This will now convert every following res to a json object.
client.promiseInterceptor = res => res.json()

Typescript usage

new Cajax().get("https://interaapps.de")
    .then(async (res: CajaxResponse) => {
        console.log("Hello "+(await res.json()).name)
    })