Next.js Discord

Discord Forum

api route: 404

Unanswered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP
Version: next 12
Folder structure: pages/api/customer/cancel-subscription/index.js
(also tried to have [userId].js instead of index.js)

Axios code:
await axios.delete('customer/cancel-subscription', {
      params: {
        userId,
      },
    });


The axios has a base url of: "http://localhost:3000/api/"

Handler:
export default async function handler(req, res) {
  const { userId } = req.query;

    const response = await cancelSubscriptionRecord(userId);
    res.status(200).json(response);
  
}

(cancelSubscriptionRecord is a function that has DB code)

0 Replies