Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
API resolved without sending a response for /api/campaign/dynamicid, this may result in stalled requests. in next js

I am getting an error while running amazon ses code in next js. don't know where am wrong, please try to fix my error. If you have any question please free feel to ask.

sendmail.js

This is the sendmail.js file where i got error. here I am using amazon ses for sending mail.

var AWS = require('aws-sdk');

AWS.config.update({ region: process.env.AWS_REGION });

// var mail = '';

function sendMail(Email) {

    var result;
    // Create sendEmail params 
    var params = {
        Destination: { /* required */
            CcAddresses: [
                Email,
                /* more items */
            ],
            ToAddresses: [
                Email,
                /* more items */
            ]
        },
        Message: { /* required */
            Body: { /* required */
                Html: {
                    Charset: "UTF-8",
                    Data: "HTML_FORMAT_BODY"
                },
                Text: {
                    Charset: "UTF-8",
                    Data: "TEXT_FORMAT_BODY"
                }
            },
            Subject: {
                Charset: 'UTF-8',
                Data: 'Test email'
            }
        },
        Source: 'abc@gmail.com', /* required */
        ReplyToAddresses: [
            'abc12@gmail.com',
            /* more items */
        ],
    };

    // Create the promise and SES service object
    var sendPromise = new AWS.SES({ apiVersion: '2010-12-01' }).sendEmail(params).promise();

    // Handle promise's fulfilled/rejected states
    sendPromise.then(
        function (data) {
            result = 'Success';
        }).catch(
            function (err) {
                result = 'Failed';
            });
}

export default sendMail;

dynamicid.js

This is the dynamic id .js file where i wrote my endpoint code

import { getDataFromSheets } from '../../../libs/sheets';
import sendmail from '../../../libs/ses/sendmail';

export default function handler(req, res) {
  var data;
  getDataFromSheets()
    .then(sheet => {
      data = sheet.length
      for (var i = 1; i < data; i++) {
        sendmail(sheet[i].Email)
      }
    })
    .catch(err => console.log(err))

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Each endpoint function must end the request-response cycle by sending a response ( res.send(), res.json(), res.end(), etc). So the solution would be:

export default function handler(req, res) {
  var data;
  getDataFromSheets()
    .then(sheet => {
      data = sheet.length
      for (var i = 1; i < data; i++) {
        sendmail(sheet[i].Email)
      }
      res.json({status: 'success', message: 'email has been sent'})
    })
    .catch(err => {
      console.log(err)
      res.json({status: 'fail', error: err})
    })
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!