0

I recently had a question on how to query a list of products from a pricebook and was told that i could use the below to do so

[SELECT Id, Product2Id, Product2.Name FROM PricebookEntry WHERE Pricebook2Id='12345']

As I am using React to display these data (its a menu btw) I would like to know how I can query them in the below component

import React, { useState, useEffect } from 'react';
import axios from 'axios';

function Menu() {
    useEffect(async () => {
        const result = await axios({
            method: 'get',
            url:
                'https://tahina-test2-dev-ed.my.salesforce.com/services/data/v20.0/sobjects/Pricebook2/01s2X0XyrMQAS',
            data: {
                fields: 'Name'
            },
            headers: {
                Authorization:
                    'Bearer 00D2X000001esWS!ASAAQFt1nPdywlTPnqeFBF7WSQdKKX9nKdrwrc2V9WOv3tuOFHyJ0cuq8PA4rn1'
            }
        });

        console.log(result.data);
    }, []);

    return <ul />;
}

export default Menu;

any help would be welcome as I am very new to SF :)

1 Answer 1

0

If you want to do a query, your endpoint should be /services/data/v48.0/query

For example:

https://xx.salesforce.com/services/data/v48.0/query?q=SELECT+Id,+Product2Id,+Product2.Name+FROM+PricebookEntry+WHERE+Pricebook2Id='12345'

See the doc

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .