๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
(node:1475) UnhandledPromiseRejectionWarning: Error: Bad Request
at Request.http [as _callback] (node_modules/@sendgrid/client/src/classes/client.js:124:25)
at Request.self.callback (node_modules/request/request.js:185:22)
at Request.emit (events.js:182:13)
at Request.<anonymous> (node_modules/request/request.js:1161:10)
at Request.emit (events.js:182:13)
at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:1475) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1475) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
๋ด ์ฝ๋๋ nextjs ์ฑ์ ์ผ๋ถ๋ก ์ต์คํ๋ ์ค ๋ฐ ๋ ธ๋์ ์์ต๋๋ค.
const express = require('express')
const next = require('next')
const bodyParser = require('body-parser')
const sgMail = require('@sendgrid/mail');
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
sgMail.setApiKey(myKey);
const send = ({ email, name, text }) => {
const message = {
to: '[email protected]',
from: email,
subject: 'New message from',
text: text,
}
return new Promise((resolve, reject) => {
sgMail.send(message, (error, info) =>
error ? reject(error) : resolve(info)
)
})
}
app.prepare().then(() => {
const server = express()
server.use(bodyParser.json())
server.get('*', (req, res) => {
return handle(req, res)
})
server.post('/api/contact', (req, res) => {
const { email, name, message } = req.body
send(email, name, message)
res.send('success')
})
server.listen(3000, (err) => {
if (err) throw err
console.log('> Read on http://localhost:3000')
})
})
์๋ ํ์ธ์ @AWR14 ์ ๋๋ค .
์ด ์ค๋ฅ๋ ์ฝ์ ๊ฑฐ๋ถ๋ฅผ ์ฒ๋ฆฌํ์ง ์์ ๋ ๋ฐ์ํฉ๋๋ค. ๋ค์ ์ ์์ ๋๋ค.
๊ฐ์ฌ ํด์!
๋ง์์ ๋ด์,
์๋จธ
@AWR14 ,
๋น์ทํ ๋ฌธ์ ์ ์ง๋ฉดํ๋๋ฐ from
์ด๋ฉ์ผ ํ๋๊ฐ ์ ํจํ ์ด๋ฉ์ผ์ธ์ง ํ์ธํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
@hkadyanji , (๊ทธ๋ฆฌ๊ณ ํจ๊ป ์ค๋ ๋ค๋ฅธ ์ฌ๋) ์ด์ํ๊ฒ๋ ๋ชจ๋ ํ๋๋ฅผ ์ ๊ณตํ์ง ์๊ณ ์ต์ํ ๊ณต๋ฐฑ์ด ์๋์ง ํ์ธํ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํ๋๋ฅผ ""๋ก ์ค์ ํ๋ ๋์ ๊ทธ๊ฒ์ " "(๋ฐ์ดํ ์์ ๊ณต๋ฐฑ)์ผ๋ก ์ฎ๊ธฐ๋ฉด ๋ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค. ์ ๋ ์ด๊ฒ์ด ์๋นํ ์ด์ํ์ง๋ง ๊ณ ์ ๋ ๊ฒ์ด ๊นจ์ง ๊ฒ๋ณด๋ค ๋ซ์ต๋๋ค. :) ํผ๋๋ฐฑ/์ธ์ฌ์ดํธ๊ฐ ์๋ ์ฌ๋์ด ์์ผ๋ฉด ์๊ณ ์ถ์ต๋๋ค...
๊ณตํํ๊ฒ ๋งํ๋ฉด, ๋๋ ๊ณต๋ฐฑ์ ํ์ฉํ๊ธฐ ์ํด to: ๋ฐ from: ํ๋๋ฅผ ํ ์คํธํ์ง ์์์ต๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ๋ด ์ฑ์ ๊ฐ์ด ์์ผ๋ฏ๋ก ํ์์ฑ์ ๋ณด์ง ๋ชปํ๊ธฐ ๋๋ฌธ์ ๋๋ค. ๋๋ ์์ ํ ์ชฝ์์ ๋ฐฉ์กํ ๊ฒ์ด๊ณ , ๋ฏธ๋ ๋ฒ์ ์์ ๊ทธ๋ ์ง ์๋ค๋ ๊ฒ์ด ์ฆ๋ช ๋ ๋๊น์ง ๋๋ฝ๋ ํ๋์ ์ต์ํ ๊ณต๊ฐ์ด ์๋์ง ํ์ธํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋ค์, ๋๋ ๋๊ตฌ๋ฅผ ๋๋ดํ๊ณ ์์ต๋๊น? ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ๋๊น์ง ์ด ์ฝ๋๋ฅผ ๋ค์ ๋ฐฉ๋ฌธํ์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค... ใ ใ
"@sendgrid/mail"์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค: "^6.4.0"
๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๊น? ๋์ผํ ์ค๋ฅ์ ์ง๋ฉดํ์ง๋ง ๋ด์ ๋ค๋ฅธ ์ปจํ
์คํธ์ ์์ต๋๋ค.
๋ด ์๋ฎฌ๋ ์ดํฐ์์๋ ์ ์๋ํ์ง๋ง azure์ ๊ฒ์ํ๋ฉด ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
BotFrameworkAdapter.processActivity(): 500 ์ค๋ฅ - ์ค๋ฅ: ์๋ชป๋ ์์ฒญ
(๋
ธ๋:17240) UnhandledPromiseRejectionWarning: ์ค๋ฅ: ์ค๋ฅ: ์๋ชป๋ ์์ฒญ
๊ฐ์ ๊ฒฝ๊ณ ๋ฅผ ๋ฐ์์ง๋ง ์คํ ๋ฌธ์ ๊ฐ ์๋ ๊ฒ์ ๋ด ์ค์์์ต๋๋ค. text
๋์ test
์
๋ ฅํ์ต๋๋ค.
๋ค์ ์๋ํ๊ฒ ํ๋ ค๋ฉด ๋ฐ๋ ์ฌ๋ ์ด๋ฉ์ผ๊ณผ ํค๊ฐ ์ ํจํ์ง ํ์ธํ์ธ์.
const msg = {
to: '[email protected]',
from: '[email protected]',
subject: 'Hello world',
text: 'Hello plain world!',
html: '<p>Hello HTML world!</p>',
};
์ ๊ฒฝ์ฐ์ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ ์ด์ ๋ send
API ์ ์ await๋ฅผ ์ฌ์ฉํ์ง ์์ ์ค๋ฅ๊ฐ ํฌ์ฐฉ๋์ง ์์๊ธฐ ๋๋ฌธ์
๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ค๋ฅ ์ด์ ๋ to
์ cc
๊ต์ฐจ์ ์ด ์์ต๋๋ค.ใ
to
์์ ๋ฐ๋ณต๋๋ ์ด๋ฉ์ผ์ ์ ๊ฑฐํ๋ฉด cc
๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. :)
์ฌ๊ธฐ์๋ 2๊ฐ์ง ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ์๋ชป๋ ์์ฒญ์ ํ๊ณ ํ๋ผ๋ฏธ์ค ๊ฑฐ๋ถ๋ฅผ ์ ์ ํ๊ฒ ์ฒ๋ฆฌํ์ง ์๋ ๊ฒ์
๋๋ค. ํ์์ ๊ฒฝ์ฐ ์ ์ก ์ฝ์ ๊ฒฐ๊ณผ๋ฅผ ์ฌ์ฉํ์ฌ API ํธ์ถ์ ์๋ตํ ์๊ธฐ๋ฅผ ๊ฒฐ์ ํ๊ฑฐ๋ async/await
์ฌ์ฉํด์ผ ํฉ๋๋ค. ์ ์์ ๊ฒฝ์ฐ ์์ฒญ์ด _bad_์ธ ์ด์ ๋ฅผ ๊ฒฐ์ ํ๊ธฐ ์ํด ๋ ๋ง์ ๋๋ฒ๊ทธ ๋
ผ๋ฆฌ๋ฅผ ์ถ๊ฐํด์ผ ํฉ๋๋ค. send
ํธ์ถ์์ ์ ๋ฌํ๋ ค๋ ๋ฉ์์ง ๊ฐ์ฒด๋ฅผ ๋ก๊น
ํ๋ ๊ฒ์ผ๋ก ์์ํ๊ฒ ์ต๋๋ค.
์๋ ํ์ธ์ @AWR14 ์ ๋๋ค .
์ด ์ค๋ฅ๋ ์ฝ์ ๊ฑฐ๋ถ๋ฅผ ์ฒ๋ฆฌํ์ง ์์ ๋ ๋ฐ์ํฉ๋๋ค. ๋ค์ ์ ์์ ๋๋ค.
๊ฐ์ฌ ํด์!
๋ง์์ ๋ด์,
์๋จธ
์ด์ ์ ๋งํฌ๋ ์ค์ ๋ก ๋ค์๊ณผ ๊ฐ์ต๋๋ค. https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/success-failure-errors.md ;)
๊ทธ๋ฌ๋ ๊ทธ๊ฒ์ ์๋ฆ๋ค์ด ํ์ ์ด์ ์ง์ง ์ค๋ฅ๊ฐ ๋ฌด์์ธ์ง ์ดํดํ ์ ์๊ฒ ๋์์ต๋๋ค! ๊ฐ์ฌํฉ๋๋ค!
@AWR14 ,
๋น์ทํ ๋ฌธ์ ์ ์ง๋ฉดํ๋๋ฐfrom
์ด๋ฉ์ผ ํ๋๊ฐ ์ ํจํ ์ด๋ฉ์ผ์ธ์ง ํ์ธํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
์ ํํ๋ sendgrid ๊ด๋ฆฌ์ ๋ด์์ ์ด๋ฉ์ผ ์ํ๋ฅผ ํ์ธํด์ผ ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@AWR14 ,
๋น์ทํ ๋ฌธ์ ์ ์ง๋ฉดํ๋๋ฐ
from
์ด๋ฉ์ผ ํ๋๊ฐ ์ ํจํ ์ด๋ฉ์ผ์ธ์ง ํ์ธํ์ฌ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.