I am using proxy in reactjs its working on deveopment but after build proxy doesn't works how to solve it. Help Me

54 Views Asked by At

Anybody any can help me to fix this (Or) Develop any other way to complete this in Reactjs.

I am using this on package.json

"proxy": "https://affiliate-api.flipkart.net",

And App.js Code is

import React, { Component } from "react";
import axios from "axios";

class Menutry extends Component {
  constructor() {
    super();
    this.state = {
      fdata: [],
    };
  }
  componentDidMount() {
    var config = {
      headers: {
        "Fk-Affiliate-Id": "onlinesho41",
        "Fk-Affiliate-Token": "bd6298b80c164655bf12a15d405cf09f",
      },
    };
    axios
      .get("/affiliate/api/onlinesho41.json", config)
      .then((data) => {
        console.log(data.data.apiGroups.affiliate.apiListings);
        this.setState({ fdata: data.data.apiGroups.affiliate.apiListings });
      })
      .catch(console.log);
  }
  render() {
    let Repltxt;
    return (
      <ul>
        {Object.keys(this.state.fdata).map((apiCat, index) => (
          <li key={index}>
            {
              (Repltxt = this.state.fdata[apiCat].availableVariants[
                "v1.1.0"
              ].resourceName.replace(/_/gi, " "))
            }
          </li>
        ))}
      </ul>
    );
  }
}

export default Menutry;

After the build proxy not but current window url display infront of api url. Error

Console error image here

0

There are 0 best solutions below