Closed henrikekblad closed 9 years ago
nvm, PR checker is broken :grin: Only works on master for some reason :confused: I'll test it locally.
Weird.. I see now that I seem to get two callbacks.
err: { [Error: getaddrinfo ENOTFOUND webservices.amazon.co.uk] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'webservices.amazon.co.uk' } res: undefined
err: No response (check internet connection) res: undefined
Just a sec.. I think I've found it.
Ok, seeing the correct behaviour here now. Sorry for the push flooding.
cool can you squash the commits and push --force?
Hmm. never done that before. Do you have some nifty command line tricks?
sure :smile:
Run git rebase -i HEAD~3
and read the instructions.
Let me know if you face any difficulties.
Ok, done (I hope).
Yeah! Looks good :+1:
Thank you for your contribution!
I'll ship it to npm as 2.2.3 in a few minutes.
Hi, I am also getting the same error when trying to use it in Firebase-cloud-functions, below is my code:
var express = require('express');
var fs = require('fs');
var amazon = require('amazon-product-api');
var _ = require('lodash');
var request = require('request');
var functions = require('firebase-functions');
const admin = require('firebase-admin');
// CORS Express middleware to enable CORS Requests.
const cors = require('cors')({
origin: true
});
admin.initializeApp(functions.config().firebase);
//allattentionhere@gmail.com
var client = amazon.createClient({
awsId: "aws ID",
awsSecret: "aws Secret",
awsTag: "aws Tag"
});
//https://us-central1-pricestalker-ba4cb.cloudfunctions.net/amazonsearch?asin=asincode
exports.amazonsearch = functions.https.onRequest((req, res) => {
if (req.method === 'PUT') {
res.status(403).send('Forbidden!');
}
cors(req, res, () => {
const asin = req.query.asin;
if (!asin) {
asin = req.body.asin;
}
client.itemLookup({
idType: 'ASIN',
itemId: asin,
responseGroup: 'ItemAttributes,Offers,Images',
domain: 'webservices.amazon.in'
}, function(err, results, response) {
if (err) {
res.status(404).send(`asin: ${asin} ` + `| response: ` + JSON.stringify(response) + JSON.stringify(err));
} else {
console.log(JSON.stringify(results));
}
});
});
});
To test, just visit url: https://us-central1-pricestalker-ba4cb.cloudfunctions.net/amazonsearch?asin=asincode
Response is:
asin: BO11 | response: undefined{"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo","hostname":"webservices.amazon.in","host":"webservices.amazon.in","port":443}
Solved, Firebase does not allow outbound network calls in free tier.
Hmm. CI fails...