R
R
Rebuslol2020-07-27 00:46:00
JavaScript
Rebuslol, 2020-07-27 00:46:00

How to display information about a specific id?

[{"id":1,"name":"Бомбический","speed":80,"price":1070,"channels_count":38,"hd_channels_count":28},{"id":2,"name":"Стартовый","speed":60,"price":390,"channels_count":39,"hd_channels_count":26},{"id":3,"name":"XXL Улётный","speed":90,"price":450,"channels_count":118,"hd_channels_count":8},{"id":4,"name":"Эксклюзивный","speed":60,"price":900,"channels_count":107,"hd_channels_count":9},{"id":5,"name":"Объединяй! Два интернета за полцены!","speed":30,"price":670,"channels_count":113,"hd_channels_count":18},{"id":6,"name":"Улётный","speed":70,"price":380,"channels_count":101,"hd_channels_count":9},{"id":7,"name":"Объединяй! Эконом","speed":100,"price":640,"channels_count":131,"hd_channels_count":12},{"id":8,"name":"ФИТ Интернет","speed":50,"price":250,"channels_count":84,"hd_channels_count":14},{"id":9,"name":"Объединяй! Хит","speed":10,"price":770,"channels_count":124,"hd_channels_count":14}]

From this you need to display information for a specific ID in order to add tariffs separately. So far, it is possible to display only the full name, price, but this is not necessary

const api = axios.create({
        baseURL: `https://tarifnik.ru/rabota/api/data_controller`
})
class App extends Component {

        state = {
                rates: []
        }

        constructor() {
                super()
                api.get().then(res => {
                this.setState({ rates: res.data})
                })
        }
        render() {
                return(
                        <div>
                                <div> Скорость
                                <a>
                                { this.state.rates.map(rates => <h2 key={rates.id}>{rates.name}</h2>)}
                                </a>
                                </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynatik001, 2020-07-27
@Rebuslol

try to use

const result = words.filter(rates => rates.id == id);

So what do you want to do next

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question