A
A
Alexander Osadchy2022-02-16 22:33:06
React
Alexander Osadchy, 2022-02-16 22:33:06

How to convert a request to react?

Hello!

I have a small script on Next.js

import type { NextApiRequest, NextApiResponse } from 'next';

export default async (req: NextApiRequest, res: NextApiResponse) => {
  try {
    const { message } = await list.members().create({ address: req.body.email });
    res.status(200).json({ message });
  } catch (e) {
    res.status(e.statusCode).json({ message: e.message });
  }
};


And here the response and request statuses are very conveniently implemented: Does pure react have such things?

req: NextApiRequest, res: NextApiResponse

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2022-02-17
@Casufi

https://developer.mozilla.org/en-US/docs/Web/API/F...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question