Dynamic route not working

I am currently utilizing the plugin-api with the following versions: - @sapphire/framework": "^4.2.2 - @sapphire/plugin-api": "^5.0.2" Prior to updating to the most recent version, everything was functioning without issue. However, after updating, when I set a route as anyRoute/:code, attempting to access it results in a 404 error. On the other hand, if I set the route to anyRoute, I am able to access it without any problems. Example:
public constructor(context: Route.Context, options: Route.Options) {
super(context, {
...options,
route: 'redeemcode/:code',
} );
}
public constructor(context: Route.Context, options: Route.Options) {
super(context, {
...options,
route: 'redeemcode/:code',
} );
}
Solution:
Okay! It started working after deleting the node_modules folder and reinstalling.
Jump to solution
4 Replies
Favna
Favna•2y ago
it works just fine when I try it.
import { ApiRequest, ApiResponse, methods, Route } from '@sapphire/plugin-api';

export class UserRoute extends Route {
public constructor(context: Route.Context, options?: Route.Options) {
super(context, {
...options,
route: 'redeemcode/:code'
});
}

public [methods.GET](request: ApiRequest, response: ApiResponse) {
response.json({ message: `Code: ${request.params.code}` });
}

public [methods.POST](request: ApiRequest, response: ApiResponse) {
response.json({ message: `Code: ${request.params.code}` });
}
}
import { ApiRequest, ApiResponse, methods, Route } from '@sapphire/plugin-api';

export class UserRoute extends Route {
public constructor(context: Route.Context, options?: Route.Options) {
super(context, {
...options,
route: 'redeemcode/:code'
});
}

public [methods.GET](request: ApiRequest, response: ApiResponse) {
response.json({ message: `Code: ${request.params.code}` });
}

public [methods.POST](request: ApiRequest, response: ApiResponse) {
response.json({ message: `Code: ${request.params.code}` });
}
}
Solution
taO
taO•2y ago
Okay! It started working after deleting the node_modules folder and reinstalling.
taO
taO•2y ago
Sorry 😦
Favna
Favna•2y ago
That's basically the "did you try turning it off and on again" of NodeJS https://www.youtube.com/watch?v=nn2FB1P_Mn8&t=10s
Cam G Videos
YouTube
IT Crowd - Have You Tried Turning It Off And On Again?
NEW CHANNEL: https://www.youtube.com/channel/UCEjwgKUADCmMzhGHrlueKYw This channel will become inactive in a few weeks. Thank you all for watching :)
Want results from more Discord servers?
Add your server