Hi !
I just try this code for watch if dns promise works and the challenge has been validated.
But… It has not finish.
'use strict';
const express = require('express');
const mongo = require('mongodb');
const mongoose = require('mongoose');
const cors = require('cors');
const app = express();
const http = require('http').Server(app);
const dns = require('dns').promises;
app.use(cors());
app.use('/public', express.static(process.cwd() + '/public'));
app.get('/', (req, res) => res.sendFile(process.cwd() + '/views/index.html'));
app.get("/api/hello", (req, res) => res.json({greeting: 'hello API'}));
app.post('/api/shorturl/new', (req, res) => {
console.log(req.body)
return dns.lookup('')
.then(({ address }) => {
return res.status(200).send({ original_url: "www.google.com", short_url: 1 });
})
.catch(err => {
return res.status(400).send({ error: "invalid URL"});
})
});
http.listen(process.env.PORT || 3000);