nuxt-resource-module
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "nuxt-resource-module", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "@nuxtjs/axios based API request wrapper for Nuxt.js", | ||
"main": "dist/module.js", | ||
"types": "index.d.ts", | ||
"repository": "https://github.com/mya-ake/nuxt-resource-module.git", | ||
"bugs": { | ||
"url": "https://github.com/mya-ake/nuxt-resource-module/issues" | ||
}, | ||
"author": "mya-ake <make.app.ts@gmail.com>", | ||
@@ -18,3 +23,3 @@ "license": "MIT", | ||
"test:unit:watch": "jest --config jest.config.js --watch", | ||
"release": "standard-version" | ||
"release": "run-s lint test:unit build standard-version" | ||
}, | ||
@@ -34,9 +39,16 @@ "devDependencies": { | ||
"tslint-plugin-prettier": "^2.0.0", | ||
"typescript": "^3.1.3" | ||
"typescript": "^3.1.3", | ||
"vue": "^2.5.17", | ||
"vue-router": "^3.0.1" | ||
}, | ||
"dependencies": { | ||
"@nuxtjs/axios": "^5.3.3", | ||
"vue": "^2.5.17", | ||
"vue-router": "^3.0.1" | ||
} | ||
"@nuxtjs/axios": "^5.3.3" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"nuxt.js", | ||
"axios" | ||
] | ||
} |
@@ -1,2 +0,2 @@ | ||
# nuxt-resource-module | ||
# Nuxt.js Resource Module | ||
@@ -6,1 +6,65 @@ ## Status | ||
[![CircleCI](https://circleci.com/gh/mya-ake/nuxt-resource-module/tree/master.svg?style=svg)](https://circleci.com/gh/mya-ake/nuxt-resource-module/tree/master) | ||
## Features | ||
- [@nuxtjs/axios](https://github.com/nuxt-community/axios-module)をラップした HTTP リクエストモジュール | ||
- asyncData と fetch でリクエストしたリクエストを遷移後まで遅延させられます | ||
- リンクをクリックしてすぐに遷移します | ||
- 遷移後リクエストを行い、response.dataをそのままdataプロパティにマッピングします | ||
- SSR 時は遅延させずにそのままリクエストします | ||
- リクエスト時にレスポンスを加工する処理を追加できます | ||
## Install | ||
``` | ||
$ yarn add nuxt-resource-module | ||
``` | ||
### nuxt.config.js | ||
```JavaScript | ||
module.exports = { | ||
// ... | ||
modules: [ | ||
'nuxt-resource-module', // required before @nuxtjs/axios | ||
'@nuxtjs/axios', | ||
], | ||
// ... | ||
} | ||
``` | ||
## Usage | ||
```JavaScript | ||
async asyncData({ app, error }) { | ||
// default request | ||
const response = await app.$_resource.get({ | ||
url: '/users', | ||
}); | ||
// delay request | ||
const response = await app.$_resource.delay.get({ | ||
url: '/users', | ||
// response.data mapper | ||
dataMapper(response: AxiosResponse) { | ||
const { data } = response; | ||
return data ? { users: data.users } : { users: [] }; | ||
}, | ||
// response | ||
processor(response: AxiosResponse) { | ||
if (response.status !== 200) { | ||
error({ statusCode: response.status, message: 'Request error' }) | ||
} | ||
return response; | ||
}, | ||
}); | ||
} | ||
``` | ||
## Options | ||
coming soon... | ||
- default processor | ||
- etc. |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
1
1
69
20434
15
19
329
- Removedvue@^2.5.17
- Removedvue-router@^3.0.1
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/parser@7.26.5(transitive)
- Removed@babel/types@7.26.5(transitive)
- Removed@vue/compiler-sfc@2.7.16(transitive)
- Removedcsstype@3.1.3(transitive)
- Removednanoid@3.3.8(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedpostcss@8.5.1(transitive)
- Removedprettier@2.8.8(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedsource-map-js@1.2.1(transitive)
- Removedvue@2.7.16(transitive)
- Removedvue-router@3.6.5(transitive)