i was trying to invoke the appsync using lambda, but i was getting the following error ```A function update is still in
Posted: Fri Jul 01, 2022 5:34 am
i was trying to invoke the appsync using lambda, but i was getting the following error```A function update is still in progress so the invocation went to the previously deployed code and configuration.Test Event NametestResponse{ "statusCode": 200, "body": { "errors": [ { "message": "Request body is empty.", "errorType": "MalformedHttpRequestException" } ] }}Function LogsSTART RequestId: 784af0c9-57f3-4e98-8641-b3828e663fec Version: $LATEST2022-06-28T20:17:20.027Z 784af0c9-57f3-4e98-8641-b3828e663fec INFO chunk <Buffer 7b 0a 20 20 22 65 72 72 6f 72 73 22 20 3a 20 5b 20 7b 0a 20 20 20 20 22 6d 65 73 73 61 67 65 22 20 3a 20 22 52 65 71 75 65 73 74 20 62 6f 64 79 20 69 ... 68 more bytes>2022-06-28T20:17:20.028Z 784af0c9-57f3-4e98-8641-b3828e663fec INFO dataString { "errors" : [ { "message" : "Request body is empty.", "errorType" : "MalformedHttpRequestException" } ]}2022-06-28T20:17:20.048Z 784af0c9-57f3-4e98-8641-b3828e663fec INFO in 1 response { errors: [ { message: 'Request body is empty.', errorType: 'MalformedHttpRequestException' } ]}2022-06-28T20:17:20.067Z 784af0c9-57f3-4e98-8641-b3828e663fec INFO { errors: [ { message: 'Request body is empty.', errorType: 'MalformedHttpRequestException' } ]}END RequestId: 784af0c9-57f3-4e98-8641-b3828e663fecREPORT RequestId: 784af0c9-57f3-4e98-8641-b3828e663fec Duration: 492.77 ms Billed Duration: 493 ms Memory Size: 128 MB Max Memory Used: 60 MB Init Duration: 158.84 msRequest ID784af0c9-57f3-4e98-8641-b3828e663fec```This is my code. "use strict";var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); });};Object.defineProperty(exports, "__esModule", { value: true });exports.handler = void 0;//const http = require('http');const https = require('https');const handler = (event = {}, context = {}) => __awaiter(void 0, void 0, void 0, function* () { let dataString = ''; const query = ` query Message { getMessage { data } } `; const options = { hostname: '7xpo2hjitnfs5b3odkpsrugehu.appsync-api.us-east-2.amazonaws.com', path: '/graphql', method: 'POST', headers: { 'x-api-key': 'da2-zhj77qod5vfh7lnlfarazw4rwm', 'Content-Type': 'application/json' }, body: JSON.stringify({ query, variables: { now: new Date().toISOString(), } }), }; const response = yield new Promise((resolve, reject) => { const request = https.request(options, function (res) { res.on('data', chunk => { dataString += chunk; console.log("chunk", chunk); }); res.on('end', () => { let response = ''; console.log('dataString', dataString); if (dataString) { try { response = JSON.parse(dataString); console.log("in 1 response", response); } catch (e) { response = dataString; } } console.log(response); resolve({ statusCode: 200, body: response }); }); }); request.on('error', (e) => { console.log('error', JSON.stringify(e)); reject({ statusCode: 500, body: JSON.stringify(e) }); }); request.end(); }); return response;});exports.handler = handler;//# sourceMappingURL=index.js.map