link959 link960 link961 link962 link963 link964 link965 link966 link967 link968 link969 link970 link971 link972 link973 link974 link975 link976 link977 link978 link979 link980 link981 link982 link983 link984 link985 link986 link987 link988 link989 link990 link991 link992 link993 link994 link995 link996 link997 link998 link999 link1000 link1001 link1002 link1003 link1004 link1005 link1006 link1007 link1008 link1009 link1010 link1011 link1012 link1013 link1014 link1015 link1016 link1017 link1018 link1019 link1020 link1021 link1022 link1023 link1024 link1025 link1026 link1027 link1028 link1029 link1030 link1031 link1032 link1033 link1034 link1035 link1036 link1037 link1038 link1039 link1040 link1041 link1042 link1043 link1044 link1045 link1046 link1047 link1048 link1049 link1050 link1051 link1052 link1053 link1054 link1055 link1056 link1057 link1058 link1059 link1060 link1061 link1062 link1063 link1064 link1065 link1066 link1067 link1068 link1069 link1070 link1071 link1072 link1073 link1074 link1075 link1076 link1077 link1078 link1079 link1080 link1081 link1082 link1083 link1084 link1085 link1086 link1087 link1088 link1089 link1090 link1091 link1092 link1093 link1094 link1095

[Vue.js] Can I use Nuxt.js to render data from database? Subscribe to RSS

when in the process of learning nuxt.js, so I’ve decided to create a small project with it. I read couple of documentation. There’s something that I did not fully understand though.

If Nuxt can use several backend framework (express, hapi, koa, others), can I use something like sequelize and create a fullstack app with it?

For example, I use express and sequelize to access a database. Then using nuxt’s asyncData to rendered it to my component without fetching using axios. Is it possible? Need some information about this

Solution :

Nuxt.js is backend agnosticmeaning you can use any backend technology to power the Nuxt.js (or Vue.js) application. In the case you can create the backend using express and sequelize. You cant directly access the database from the nuxt, you need to create interfaces that will provide data in the asyncdata.

<script>
import Customers from ‘~/plugins/Customers.js’
export default{
asyncData ({ params }) {
return Customers.getCustomers()
.then(result => { customers: result.users})
}
}
</script>

In the following example, getCustomers() returns a Promise which contains the users.
In the Customers.js you create an interfaces which will access the database. Hope this gives you an idea how you can implement, it is always recommended you abstract away the frontend and backend so that in future if you wish to change the backend stack the it will be easy to update, also making API requests to the express server in the asyndata would be good.