Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
github.com/kamijin-fanta/vue-async-data
Async data loading plugin for Vue.js
npm install vue-async-data-2
// use as global plugin
import Vue from 'vue';
import { AsyncDataPlugin } from './utils/asyncdata';
Vue.use(AsyncDataPlugin);
// use as locally mixin
import { AsyncDataMixin } from './utils/asyncdata';
export default {
mixins: [ AsyncDataMixin ],
}
<template>
<div>
<p v-if="userNameLoading">Loading...</p>
<p v-else-if="userNameError">Error: {{ userNameError }}</p>
<p v-else>Hello {{ userName }} !</p>
<button v-on:click="asyncReload('userName')">Reload userName</button>
</div>
</template>
<script>
export default {
name: 'show-data',
asyncData: {
userName () {
return new Promise((resolve, reject) => {
setTimeout(_ => {
if (Math.random() > 0.5) {
resolve('risa');
} else {
reject('fetch error...');
}
}, 1000);
})
},
},
}
</script>
specify a function that returns Promise
.
you can also specify a default value.
asyncData: {
userName () { // return promise
return new Promise((resolve) => {
resolve('risa');
})
},
userNameDefault: 'unknown', // default value
userNameLazy: false, // skip run at mount?
},
refresh data.
if name arg is specified, only that field is updated.
this.asyncReload('userName')
this.asyncReload()
global reload flag.
global error flag.
if resolve
, set response.
if throw reject
, set error message.
set to true until there response.
FAQs
Unknown package
Did you know?
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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.