Coder Social home page Coder Social logo

Post With Collections about dyson HOT 4 CLOSED

webpro avatar webpro commented on May 19, 2024
Post With Collections

from dyson.

Comments (4)

webpro avatar webpro commented on May 19, 2024

I noticed an issue in setting up the defaults (i.e. not setting a default for size). I've fixed that.

So either you need to set size (as a number of function), or update to the version I just released (0.3.5) and use _.random(2, 10) as the default for size without setting anything for that prop yourself.

Does that help?

from dyson.

morten-kirstein avatar morten-kirstein commented on May 19, 2024

Hey thx for the quick reply and bugfix.

It kinda worked but, the way i'm using the POST method is kinda wrong i think.

If i want different content out and be able to switch template depending what request query i supply how do i do that?

This is how i'm doing it right now:

var g = require('dyson-generators');
var faker = require('faker');

var products = {
path: '/api/search',
cache: false,
collection: true,
size: 5,
template: {
id: g.random(5),
Producturl: faker.internet.domainName(),
PicutureUrl: "",
name: "xxxxxx",
stock: {
city: {
name: g.address.city(),
amount: g.random(20)
},
central: g.random(40)
}
},
container: {
layout: 'group',
product: function(params, query, data){
return data;
}
}
};

module.exports = products;

from dyson.

morten-kirstein avatar morten-kirstein commented on May 19, 2024

Sorry that was my get. The post is here.

var g = require('dyson-generators');
var faker = require('faker');

var domainName = 'http://www.xxx/';

var outputtemplate = {
ProductUrl: domainName + faker.helpers.randomNumber(555),
ImageUrl: faker.image.imageUrl(30,30,'cats'),
ProductName: faker.company.catchPhraseAdjective(),
ProductSupplierNo: faker.helpers.randomNumber(9999999999)
};

var products = {
path: '/api/search',
collection: true,
size: 5,
template: outputtemplate
};

module.exports = products;

from dyson.

webpro avatar webpro commented on May 19, 2024

FYI, code is much better readable if you'd put it in code blocks (you can still edit).

I think your question might be answered by saying that most things (the template itself, or individual template properties) can be a function (https://github.com/webpro/dyson#endpoint-configuration), and these functions are invoked with the request parameters and query.

from dyson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.