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•15mo 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•15mo ago
Okay! It started working after deleting the node_modules folder and reinstalling.
taO
taO•15mo ago
Sorry 😦
Favna
Favna•15mo 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 :)