このエンドポイントに適切なポストリクエストを行う方法。私はPOSTMANを使用するとき、私は正しい応答を得るが、私は503エラーを取得する以下の関数を使用して呼び出すとき。私によれば、その電話はうまくいくようです。私はあなたの助けに感謝します!!要求モジュールNodeJs expressを使用してポストリクエストを作成する方法
const request = require('request');
const express = require('express');
// Initialize request
var img64Data = "/9j/4AAQSkZJRgABAQAAAQABAAD/2w… "; // Include the entire base64 encoding. // Shown Below in the next page
var send = {"img64": img64Data};
var api_address = "https://8n78hbwks0.execute-api.us-west-2.amazonaws.com/dev/";
// Make Post Request
module.exports = app => {
app.post('/axe', (req, res, next) => {
console.log("inside the axe");
request.post({
url: api_address,
body: JSON.stringify(send),
headers: {"Content-Type":"application/json"}
}, function (error, response, body) {
console.log("hiii");
console.log(response.statusCode);
if (!error && response.statusCode == 200) {
// Successful call
var results = JSON.parse(body);
console.log(results) // View Results
}
});
});
};
なぜ投稿内にrequest.postを呼び出していますか?それは投稿を掲示するのと同じですか?¿?¿ –
私はそれをリクエストする方法を教えてください。それはとても役に立ち、あなたの優しさに感謝します。 – Harsha
郵便配達員のリクエストの生の書式を質問に追加できますか? –