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

@pogojs/angular-http-client

v0.0.2

Published

The library integrate api works well with Angular 10.

Downloads

3

Readme

Angular Http Client

The library integrate api works well with Angular 10.

Table of contents

Warning

The library works well with Angular 10 and Typescript versions >= 3.8.

Getting started

Step 1: Install @pogojs/angular-http-client:

NPM

npm install --save @pogojs/angular-http-client

YARN

yarn add @pogojs/angular-http-client

Step 2: Add new variable environment.ts:

export const environment = {
    production: false,
    domainUrl: 'https://jsonplaceholder.typicode.com/',
    loginUrl: 'router navigate login (ex: /login)',
    accessToken: 'localStorage token key (ex: token_key)',
    apiUrl: { // API url
        baseUrl: 'https://jsonplaceholder.typicode.com/',
        primaryUrl: '?optional',
        secondaryUrl: '?optional',
        tertiaryUrl: '?optional',
        quaternaryUrl: '?optional',
    },
};

NOTE: 
domainUrl: required
loginUrl: required
accessToken: required
baseUrl: required

Step 3: app.module.ts:

import { HttpClientModule } from '@pogojs/angular-http-client';

@NgModule({
  declarations: [AppComponent],
  imports: [HttpClientModule.forRoot(environment),],
  bootstrap: [AppComponent]
})
export class AppModule {}

Step 4: app.service.ts:

import { Injectable } from '@angular/core';
import { HttpClientService } from '@pogojs/angular-http-client';

@Injectable()
export class AppService {
    constructor(private http: HttpClientService) {

    }

    getPosts(params: any) {
        const uri = ['posts'].join('/');
        return this.http.getNotToken(uri, params);
    }
    
    createPosts(body: any) {
    	const uri = ['posts'].join('/');
    	return this.http.post(uri, body);
    }
}

Step 5: app.component.ts:

import { Component, OnInit }      from '@angular/core';
import { AppService }             from './app.service.ts';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
    providers: [AppService]
})
export class AppComponent implements OnInit {
    constructor(private service: AppService) {
    }

    ngOnInit(): void {
        this.getPosts();
    }
    
    private getPosts() {
        const params = '';
        
        this.service.getPosts(params)
            .subscribe((res) => {
                console.log('res', res);
            }
        );
    }
    
    // Posts with FormData
    public createPosts() {
    	const fileUpload = event.target.files || []; // you can handle get File or Multiple File upload
    	const data = { ...this.generalForm.value };
    	
    	const params = {
    		data: data,
    		file: fileUpload,
    	};
    	
    	// You just need to create params
        this.service.createPosts(params).subscriber((res) => {
        	// Handle code success here!
        }, (err) => {
        	// Handle code error here! 
        })
    }
}

API Method

| Name | Method | Token | Params | Description | | ------------- | ------------- | ------------- | ------------- | ------------- | | get | get | default | path: uri params:? optional options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | get method options: for url from another repo api with by default primaryUrl. | | getNotToken | get | no | path: uri params:? optional options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | get method not send token options: for url from another repo api with by default primaryUrl. | | getWithParamsToken | get | default | path: uri token: token params:? optional options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | get method options: for url from another repo api with by default primaryUrl. ex: https://jsonplaceholder.typicode.com/posts?token=token | | ------------- | ------------- | ------------- | ------------- | ------------- | | post | post | default | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | post method | | postNotToken | post | no | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | post method | | postWithParamsToken | post | default | path: uri body: data token: token options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | post method ex: https://jsonplaceholder.typicode.com/posts?token=token | | postWithFormData | post | default | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | post method | | ------------- | ------------- | ------------- | ------------- | ------------- | | put | put | default | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | put method | | putNotToken | put | no | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | Not support | | putWithParamsToken | put | default | path: uri body: data token: token options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | put method ex: https://jsonplaceholder.typicode.com/posts?token=token | | putWithFormData | put | default | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | put method | | ------------- | ------------- | ------------- | ------------- | ------------- | | delete | delete | default | path: uri options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | delete method | | deleteNotToken | delete | no | Not Defined | Not support | | deleteWithParamsToken | delete | default | path: uri token: token options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | delete method ex: https://jsonplaceholder.typicode.com/posts?token=token | | deleteWithParams | delete | default | path: uri body: data options:? { apiUrl: primaryUrl or secondaryUrl or tertiaryUrl or quaternaryUrl } | delete method |

Contributing

Contributions are welcome. You can start by looking at issues with label Help wanted or creating new Issue with proposal or bug report. Note that we are using https://conventionalcommits.org/ commits format.

Inspiration

This component is inspired by HttpClient. Check theirs amazing work and components :)