如何传递一个URL的JSON响应并将其传递给另一个JSON URL以获取结果?

时间:2020-05-08 08:09:35

标签: javascript json reactjs api

我正在尝试从此JSON URL API访问所有的“ landscapePosterId”。在上述网址的JSON响应中: “ landscapePosterId”是图像ID。我想在下面的URL中传递它以获取像 http://staging.connectingdotsinfotech.com:8080/firestixAPI_dev_2/api/v1/files/download/ 例:- http://staging.connectingdotsinfotech.com:8080/firestixAPI_dev_2/api/v1/files/download/5de660b91b5f7b5d95559311,所以我如何合并这两个API并访问图像
这是我的代码o访问“ landscapePosterId”

import React from 'react';
import Axios from 'axios';
import "react-responsive-carousel/lib/styles/carousel.min.css"; // requires a loader
import { Carousel } from 'react-responsive-carousel';


class Slider extends React.Component {

    constructor() {
        super();
        this.state = {
            data: []
        }
    }

    async componentDidMount() {
        const response = await Axios.get("http://staging.connectingdotsinfotech.com:8080/firestixAPI_dev_2/api/v2/media/fetchAllMediaSlider")
        .then((response) => {
            //console.log(response.data)
            this.setState({
                data: response.data
            })
        })
    }

    async componentDidMount() {
        const response = await Axios.post("")
    }


    render() {
        return ( 
            <>
            <Carousel>
                <div>
                    {
                        this.state.data.map((item,index) => {
                            return (
                                <div key={index}>
                                    {item.landscapePosterId}
                                </div>
                            )
                        })
                    }
                </div>
            </Carousel>
            </>
        )
    }
}

export default Slider;

0 个答案:

没有答案