[react.js]
I’m trying to refer to the content of a txt file but it if I reference to the file it will show me the path. how do I reference to the contents of the file? //the bashcode contains a bash cURL from failed API calls
[code]
import Bashcode from './Bashcode.txt';
<button onClick={() => navigator.clipboard.writeText(Bashcode)}>Naar Postman</button>
[expectations]
I was actually expecting to reference to the file to get or just the file name or the contents but turned out it referenced the path to the file.
2
Answers
Use the
File Reader
module to achieve this.