• Creator
  • #2141872

    MERN Object to Array

    by mrsrv7 ·

    i have a mongodb database and it contains an object which itself contains an object

    let retailer = new Schema({

    product_brand: String,

    price : {
    oprice_1 : Number,

    dprice_2: Number,

    and i m connecting Node with it via mongoose and getting the same in React through states

    this.state = {
    products : [],
    searchfield: ”,
    retailerPrice : []

    axios.get(‘http://localhost:6000/Retailer%27).then(res => {
    this.setState({ products:});
    }).catch((err) => console.log(err))

    am using this for accessing.

    when i am using this.setState({ products:}); all incoming data is getting into products[] itself but i want to store the price in seperate array and display elsewhere

    how can i?

You are posting a reply to: MERN Object to Array

The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our Community FAQs for details. All submitted content is subject to our Terms of Use.

All Answers

Share your knowledge