A DevLess backend connector for NuxtJS (https://nuxtjs.org)
Connect your Nuxt app to the DevLess backend to store data.
- Download or clone the
devless.js
lib into the plugins directory of your nuxt application - Open
nuxt.config.js
and include the lib in the plugin section. Read more on how to add plugins here - Install the Nuxt Axios Module @nuxtjs/axios
- Add
axios
config to thenuxt.config.js
. Recommend to proxy all requests.
axios: {
proxy: true,
https: true,
retry: {
retries: 3
}
},
proxy: {
'/api/v1/': {
target: 'https://kpela.herokuapp.com/',
changeOrigin: true
}
}
- Login into your DevLess instance, head to the App section to grab the instance details to config the nuxt app (
nuxt.config.js
) Add the details todevless
under theenv
key. Read more
env: {
devless: {
proxy: true, // When set to `true` would use the proxy url for all requests(ssr) but `false` would use the absolute path for the DevLess instance
host: 'YOUR_DEVLESS_URL',
'devless-token': 'YOUR_DEVLESS_TOKEN',
}
}
- Restart the dev server
Refer to JS Library for more options
- Query Data
this.$devless.queryData('service_name', 'table_name', extras_params)
.then(res => console.log(res))
.catch(e => console.log(e))
The extras_params
can be ignored if not available.
2. Add Data
let data = {
name: 'Tsatsu'
}
this.$devless.addData('service_name', 'table_name', data)
.then(res => console.log(res))
.catch(e => console.log(e))
- Update Data
let data = {
name: 'Tsatsu'
}
this.$devless.updateData('service_name', 'table_name', 'identifier', 'value', data)
.then(res => console.log(res))
.catch(e => console.log(e))
- Delete Data
this.$devless.updateData('service_name', 'table_name', 'identifier', 'value')
.then(res => console.log(res))
.catch(e => console.log(e))
- Method Calls
let params = []
this.$devless.call('service_name', 'method_name', params)
.then(res => console.log(res))
.catch(e => console.log(e))
params
can be ignored if not available
6. Login
let payload = {
email: 'john@doe.com'
password: '******'
}
this.$devless.login(payload)
.then(res => console.log(res))
.catch(e => console.log(e))
- Register
let payload = {
first_name: 'John',
last_name: 'Doe',
phone_number: '233201234567',
email: 'john@doe.com'
password: '******'
}
this.$devless.register(payload)
.then(res => console.log(res))
.catch(e => console.log(e))
- Logout
let token = 'LOGGED_IN_USER_TOKEN'
this.$devless.logout(token)
.then(res => console.log(res))
.catch(e => console.log(e))
Submit PRs. Test & Improvements needed.
E-mail: tsatsu@devless.io