Giter Site home page Giter Site logo

Comments (5)

bm777 avatar bm777 commented on August 31, 2024

@Suchlikesamsung what do you mean by internal communication? IPC or nextjs API way ?

from nextron.

Suchlikesamsung avatar Suchlikesamsung commented on August 31, 2024

@Suchlikesamsung what do you mean by internal communication? IPC or nextjs API way ?

This is endpoint communication using pages/api.

from nextron.

bm777 avatar bm777 commented on August 31, 2024

ok. gotcha.
what I simply do is define functions inside the pages/api/method.js file and export each of them. And I just call them in my pages.

Screenshot 2023-12-12 at 12 45 51

from nextron.

Suchlikesamsung avatar Suchlikesamsung commented on August 31, 2024

The problem is that it works normally on localhost, but when I create a product, it doesn't work as above. Do I need to call the function directly in a production environment?

this is my chargerborad component

const fetchData = async () => {
try{
const response = await fetch('/api/userdata');
const result = await response.json();
console.log(result.data)
return result.data;
} catch (error){
console.error("component mount error!",error);
throw error;
}
}

const ChargerBoard: React.FC = () => {
const [data, setData] = useState<string | null>(null);
useEffect(() => {
fetchData()
.then((apidata) => setData(apidata))
.catch((error) => console.error("error",error));
},[]);

return (

hello world!

)
};

export default ChargerBoard;

좋아요. 알았어. 내가 하는 일은 pages/api/method.js파일 내부에 함수를 정의하고 각각을 내보내는 것입니다. 그리고 난 그냥 내 페이지에서 그들을 호출합니다.

스크린샷 2023-12-12 at 12 45 51

from nextron.

bm777 avatar bm777 commented on August 31, 2024

@Suchlikesamsung I cannot see your image, you just have to call that function in prod, and it works. and in that function, you call fetch your data from anywhere without issue :)

from nextron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.