NodeJS code generator / client doesn't fill result correctly on successful write requests
See original GitHub issueHello!
Using the samples from https://github.com/Azure/autorest/tree/master/Samples/petstore/NodeJS to access the petstore API the responses of write (for example addPet / updatePet) requests aren’t processed correct.
For example, the code
var uuid = require('uuid');
var SwaggerPetstore = require('./petstore-generated/swaggerPetstore');
var psClient = new SwaggerPetstore('http://petstore.swagger.io/v2');
var pet = {
"name": uuid.v4(),
"category": {
"id": 2,
"name": "Cats"
},
"photoUrls": [],
"tags": [],
"status": "available"
};
psClient.addPet({body: pet}, function (err, result, req, res) {
console.log('err: ', err);
console.log('result: ', result);
console.log('req: ', req);
console.log('res: ', res);
});
produces the output:
err: { [Error: {"id":1458394567226,"category":{"id":2,"name":"Cats"},"name":"3ec431eb-fc36-4d73-851c-b266a0d4efda","photoUrls":[],"tags":[],"status":"available"}]
statusCode: 200,
request:
{ rawResponse: false,
queryString: {},
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
url: 'http://petstore.swagger.io/v2/pet',
body: '{"category":{"id":2,"name":"Cats"},"name":"3ec431eb-fc36-4d73-851c-b266a0d4efda","photoUrls":[],"tags":[],"status":"available"}' },
response:
{ body: '{"id":1458394567226,"category":{"id":2,"name":"Cats"},"name":"3ec431eb-fc36-4d73-851c-b266a0d4efda","photoUrls":[],"tags":[],"status":"available"}',
headers:
{ date: 'Sat, 19 Mar 2016 16:08:01 GMT',
'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET, POST, DELETE, PUT',
'access-control-allow-headers': 'Content-Type, api_key, Authorization',
'content-type': 'application/json',
connection: 'close',
server: 'Jetty(9.2.9.v20150224)' },
statusCode: 200 } }
result: undefined
req: undefined
res: undefined
As you can see err.statusCode is 200 and in err.response.body resides the data, that I would expect in the result object.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Top 10 Most Common Node.js Developer Mistakes
js instances - the ones clients connect to concurrently. Mistake #2: Invoking a Callback More Than Once. JavaScript has relied on callbacks since...
Read more >Node.js v19.3.0 Documentation
Streams compatibility with async generators and async iterators ... instance might contain old data that needs to be // overwritten using fill(), write(), ......
Read more >Understanding and implementing rate limiting in Node.js
Explore the concept of rate limiting in Node.js — what it is, how it works, various ways to implement it, and some practical...
Read more >Rendering HTML Pages as an HTTP Server Response ...
In this article, we will consider the various approaches to rendering an HTML page. We will create a Node.js server using Express.js and ......
Read more >Express/Node introduction - Learn web development | MDN
Hello Node.js. The following example creates a web server that listens for any kind of HTTP request on the URL http://127.0.0.1:8000/ — when ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@amarzavery / @devigned: Thanks for your fast responses and explanation!
Have filed an issue at the Open API spec repo.