Socket
Book a DemoInstallSign in
Socket

vue-ajax-handler

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

vue-ajax-handler

[![GitHub open issues](https://img.shields.io/github/issues/David-Desmaisons/vue-ajax-handler.svg)](https://github.com/David-Desmaisons/vue-ajax-handler/issues) [![Npm version](https://img.shields.io/npm/v/vue-ajax-handler.svg)](https://www.npmjs.com/pack

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

vue-ajax-handler

GitHub open issues Npm version MIT License

Ultra minimal generic vue component to deal with ajax loading

Usage

Adapted from: https://adamwathan.me/renderless-components-in-vuejs/

Perform an ajax call and delegate the rendering to:

  • loading slot when loading

  • the default slot passing data as parameter in case of success.

  • error slot in case of error passing error as parameter in case of error.

This a generic library with no dependency on ajax library, so

  • The component parent should provide a get function that will be called with the given url.
<ajax-handler url="https://api.github.com/orgs/vuejs/repos">
  <template #default="{data}">
    <p>{{data.data[0].name}}</p>
  </template>
</ajax-handler>
import { ajaxHandler } from 'AjaxHandler'
import { get } from "axios";

export default {
  components: {
    ajaxHandler
  },
  inject: {
    get
  }
}

API

ajax-handler

slots

  • loading slot to render loading feedback

  • error slot to render error feedback

  • default slot to render data when loaded. Receives data as parameter.

props

  • url String (required)

    The url used to make ajax request.

methods

  • load()

    Perform an ajax call. Automatically called by created hook.

Installation

npm install vue-ajax-handler

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Run your tests

npm run test

Lints and fixes files

npm run lint

Run your unit tests

npm run test:unit

Customize configuration

See Configuration Reference.

Update the API section of README.md with generated documentation

npm run doc:build

Keywords

vue

FAQs

Package last updated on 15 Sep 2019

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