Commit d6294509 authored by tom's avatar tom

delete method

parent e6906e3d
...@@ -2,7 +2,7 @@ import type { RequestInit, Response } from 'node-fetch'; ...@@ -2,7 +2,7 @@ import type { RequestInit, Response } from 'node-fetch';
import nodeFetch from 'node-fetch'; import nodeFetch from 'node-fetch';
// first arg can be only a string // first arg can be only a string
// FIXME migrate to RequestInfo later // FIXME migrate to RequestInfo later if needed
export default function fetch(path: string, init?: RequestInit): Promise<Response> { export default function fetch(path: string, init?: RequestInit): Promise<Response> {
const headers = { const headers = {
accept: 'application/json', accept: 'application/json',
......
import type { NextApiRequest, NextApiResponse } from 'next'
import fetch from 'api/utils/fetch';
export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
const { id } = _req.query;
const url = `/account/v1/user/tags/address/${ id }`;
switch (_req.method) {
case 'DELETE': {
await fetch(url, { method: 'DELETE' })
res.status(200);
break;
}
default: {
res.setHeader('Allow', [ 'DELETE' ])
res.status(405).end(`Method ${ _req.method } Not Allowed`)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment