Questions tagged [koa-router]

Router middleware for koa.

Router middleware for koa.

https://github.com/alexmingoia/koa-router

139 questions
0
votes
1 answer

How can i get the 'id' when i want to match url like ''/index?id=xxx'' in koa-router

How can i get the 'id' when i want to match url like '/index?id=xxx' in koa-router? most articles on the web usually use url lick '/index/:id',but the back-end interfaces are not the case.
Albin Liao
  • 35
  • 1
  • 1
  • 4
0
votes
2 answers

Handle POST requests with koa-proxy

I am trying to configure proxy middleware koa-proxy. It works fine for all GET requests but POST requests with body don't reach the actual API. let koa = require('koa'); let staticServe = require('koa-static'); let bodyParser =…
dominik791
  • 692
  • 6
  • 17
0
votes
2 answers

koa-router 404 on node.js

platform node: v-4.4.5 koa: v-2.0.0 koa-router: v-7.0.0 here is my code /// //导入koa,和koa 1.x不同,在koa2中,我们导入的是一个class,因此用大写的Koa表示: var Koa = require('koa'); var router=require("koa-router")(); //…
chi8708
  • 1
  • 1
  • 3
0
votes
1 answer

get the request response in Koa with koa-request in node

I'm getting started with Koa ecosystem. I know it's based in generator functions (a topic that is pretty new for me, for now), and I'm having issues with a very simple task: Call an external web service, fetch the response and send it to the client…
AlexAcc
  • 601
  • 2
  • 10
  • 28
0
votes
1 answer

What's the right way to set routing for angular2 with koajs

I'm a newbie to angular2 and koajs. Maybe it's a silly question. I have an angular2 app with a routing table as below: const appRoutes: Routes = [ { path: 'pats/report/settings', component: PatsReportSettingsComponent }, { path:…
ricky
  • 2,058
  • 4
  • 23
  • 49
0
votes
1 answer

how to configure newrelic on node + koa app

I have an application using node.js, koa, koa-router. I want to add newrelic to my application, but it does not support koa. So I tried to utilise koa-newrelic (https://github.com/AfterShip/koa-newrelic) but it still does not work. i still get /*…
Alongkorn
  • 3,968
  • 1
  • 24
  • 41
0
votes
1 answer

I use koa,koa-router,koa-body in my program.But the value of this.reauest.body is "{}"

I use "form" to send data to my webserver. front-end:
niutrue
  • 3
  • 2
0
votes
1 answer

How to handle invalid GET request in Koa 2?

Below is the simple Koa server that I have setup. However, every time when an invalid GET request is performed, the server "hangs", as in the network resource tab in Chrome would specify pending. server.js const app = new Koa(); const apiUrl =…
cusX
  • 470
  • 1
  • 6
  • 17
0
votes
1 answer

Pretty print HTML output with Koa?

Is there a way to have your HTML output that comes from a Jade template be beautified? Something similar to Express's app.locals.pretty = true; ? I'm using koa-router and koa-views if that is relevant. server.js const koa = require('koa'); const…
Saad
  • 49,729
  • 21
  • 73
  • 112
0
votes
1 answer

How do I send GET response of REST api to React client using Koa2 and koa-router?

I have a REST api set up with koa and koa-router. I can hit an api end-point and console.log(ctx.body) and I see what I want and expect to see. In this case, I expect to see a json object with a URL and that is what I see on the node side when I…
Zigrivers
  • 409
  • 7
  • 18
0
votes
2 answers

Exporting routes in Koa

I'm having a strange issue when exporting my routes. For some reason, this code works for me: app.js import Koa from 'koa' import routes from './routes/index' const app = new Koa() app.use(routes) app.listen(3000, () => { console.log('Server…
Saad
  • 49,729
  • 21
  • 73
  • 112
0
votes
2 answers

use koa-router redircet filed

I do a post ajax request to node with koa-router , and I want to redirect '/' ,but url didn`t change . this is my code : router.post('/action',function *(next){ //some action this.redirect('/'); }); my wish is '/login' = > '/' ,but …
xiao xin
  • 271
  • 1
  • 3
  • 3
0
votes
1 answer

Getting 204 using koa2 and koa-router for REST api - response body not being passed

I'm coming from Express and trying to learn Koa2 for a new project that I'm working on, but I'm struggling getting the most basic Get operation working for my app. On the server side I have a route setup that is hitting an authorization server…
Zigrivers
  • 409
  • 7
  • 18
0
votes
1 answer

How can I create a KOA path with a number?

I have an KOA endpoint. I have a quantify param that can only accept numbers, how can I enforce this directly in the KOA router? .put('/cart/:product/:quantity', async ctx => { quantity = ctx.params.quantity; ctx.body = 'my code here'; }
rat
  • 1,277
  • 16
  • 24
0
votes
0 answers

Koa-router. Need to stay on page. AJAX? How?

Code block for router is like below: router .get('/', function* (next) { this.body = dot.main(some_data); }) .post('/some_operation', function* (next) { //code for sending data to DB //this.body = dot.main(some_data); …
olegzhermal
  • 799
  • 10
  • 26
1 2 3
9
10