nuxt-community / micro-template Goto Github PK
View Code? Open in Web Editor NEWStarter template for Nuxt.js with Δ micro
Home Page: https://nuxt-micro.now.sh
Starter template for Nuxt.js with Δ micro
Home Page: https://nuxt-micro.now.sh
Hi,
I just made changes to nuxt/express to remove the BASE_URL env variable so the user doesn't have to specify it anymore :)
I migrated my app from using express to micro, my API routes work fine but I can't seem to get my nuxt.render(req, res)
to work.
This is my routes:
module.exports = (nuxt) => {
return async (req, res) => {
await dispatch()
.dispatch('/api/echo', 'POST', echo)
.dispatch('/api/users/register', 'POST', register)
.dispatch('/api/users/login', 'POST', login)
.dispatch('/api/users/edit', 'POST', editUser)
.dispatch('/api/eracks', 'POST', newRack)
.dispatch('/api/eracks/import', 'POST', importRacks)
.dispatch('/api/logs/read', 'POST', readLog)
.dispatch('/api/logs/all', 'POST', clearAllLogs)
.dispatch('/api/carriers', 'POST', pushCarrier)
.dispatch('/api/carriers', 'GET', getCarriers)
.dispatch('/api/carriers/:id', 'GET', getCarrier)
.dispatch('/api/users', 'DELETE', deleteUser)
.dispatch('/api/eracks', 'DELETE', deleteRack)
.dispatch('/api/logs', 'DELETE', deleteLog)
.dispatch('/api/eracks', 'GET', getRacks)
.dispatch('/api/eracks/:mac', 'GET', getRack)
.dispatch('/api/configs', 'GET', getConfigs)
.dispatch('/api/configs/sizes', 'GET', getSizes)
.dispatch('/api/users/:id', 'GET', getUser)
.dispatch('/api/users', 'GET', getUsers)
.dispatch('/api/logs', 'GET', getLogs)
.dispatch('*', 'GET', (req, res) => nuxt.render(req, res))(req, res)
}
}
nuxt
is passed from index.js
:
const nuxt = new Nuxt(config)
if (nuxt.options.dev) {
await new Builder(nuxt).build()
} else {
await nuxt.ready()
}
const server = micro(routes(nuxt))
What happens when I try load any route that is to one of my pages, the browser tab spinner just keeps spinning. However, when I use postman to request data from my server, it works.
I tried changing micro-route
to a more popular module micro-router
, it somehow rendered but in the terminal it keeps saying:
(node:15776) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:467:11)
at sendResponse (D:\Liang\LeetManjaro\Work\micro-nuxt\node_modules\@nuxt\server\dist\server.js:273:9)
at errorMiddleware (D:\Liang\LeetManjaro\Work\micro-nuxt\node_modules\@nuxt\server\dist\server.js:333:5)
(node:15776) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 47871)
Hi @vuchl
Do you agree deprecating this template and recommending to use create-nuxt-app instead?
Like we did for https://github.com/nuxt-community/starter-template
When I used the template, for some reason the vue files it created did not have <template>
sections.
Looking at the source, it seems to use some kind of {{{{raw}}}}
helper, presumably the one in meta.json
.
If I had to guess, I'd say that function is returning undefined or perhaps an empty string.
Using vue-cli v2.9.1
I was just testing the template, no changes at all.
(node:42238) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Request failed with status code 404
(node:42238) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
macOS Sierra
Node v7.7.3
NPM v4.1.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.