Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

99
Views
How to take path of a folder in src folder in react js?

I am creating a react.js application and in src folder i have creater two folders one for components and one for api. Now I want to import my data from a file that is in api folder how do I get the path of it? because I am trying '../../api' but got an error with this line. Please help! Below is the error.

enter image description here

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

You should right-click the required file in the API folder in vscode and click on get relative path(make sure the file where you want to access the API folder is the active file) also you need to use 3 ../ as from the first you go to cards and then componenets and then src folder where the api folder resides but from your error picture you haven't specified a file name and you can import a whole folder so you need to specific a filename after ../../api like ../../../api/script.js

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs