Skip to content

Instantly share code, notes, and snippets.

View mongoose-find-loop-create.js
Cats.find({ user: req.params.user }, function (err, product) {
if (err) {
return res.send({ isFound: false });
}
if (!product) {
return res.send({ isFound: false });
}
product.forEach(element => {
element.orderid = req.params.smaorderid
View docx-processing.js
[...]
docx.init({
ND_DEV_ID: "", // goto https://developers.nativedocuments.com/ to get a dev-id/dev-secret
ND_DEV_SECRET: "", // you can also set the credentials in the enviroment variables
ENVIRONMENT: "NODE", // required
LAZY_INIT: true // if set to false the WASM engine will be initialized right now, usefull pre-caching (like e.g. for AWS lambda)
}).catch(function (e) {
console.error(e);
});
View ebay-token-example.js
const axios = require("axios");
axios.request({
url: "/identity/v1/oauth2/token",
method: "POST",
baseURL: "https://api.sandbox.ebay.com/",
auth: {
username: "", // eBay client id
password: "" // eBay client secret
},
View test.js
try {
axios.get("here-my-url")
.then(data => res.status(200).send(data))
.catch(err => res.send(err));
} catch(err) {
console.error("ERROR", err);
}
View test.js
router.get('/brand/:smabrand', function(req, res) {
const smaquery = req.query;
// [..]
let getProductCount=async function(smaquery){
let count= await Products.countDocuments(smaquery);
console.log(count)
if (count === 0) {
return res.send("Brand not found!");