Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
- const router = express.Router();
- router.post('/api/users/register', async (req, res) => {
- try{
- const registerResponse = await fetch(`${process.env.API_URL}/api/users/register`, {
- method: 'POST',
- Headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- first_name: 'test',
- last_name: 'test',
- email: 'test@test.pl',
- password: 'qazwsx123#RF',
- })
- })
- const data = await registerResponse.json();
- return res.status(registerResponse.status).json(data)
- } catch(err){
- return res.status(500).json({
- error: 'Something went wrong when registering account'
- });
- }
- });
- module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement