1.nodejs error message
/opt/PrivateInvoice/archive.js:55
return [ response.status, response.data ];
^
TypeError: Cannot read properties of undefined (reading 'status')
at supplyArchiveToClientNode (/opt/PrivateInvoice/archive.js:55:23)
2.以下のコードで実行時にnodeが止まる
const ToClientNode = async(client_host, document_uuid, client_uuid) => {
const params = {
method : 'post',
url : `${client_host}/clientArchive`,
data : {
document_uuid,
client_uuid
}
};
let response;
try {
response = await axios(params);
} catch(err) {
if(err.code === 'ECONNRESET') {
response = {
status : 500,
data : 'ECONNRESET'
}
} else {
response = err.response;
}
}
return [ response.status, response.data ];
}
3.原因
axiosのrequireを行っていなかった
4.対策
const axios = require('axios');