I am trying to get a local file:
Resultado.js:
componentWillMount(){
axios.get('../config/db.json')
.then(function(response){
alert('ok');
})
.catch(function(error){
alert('error');
});
}
But, I am receiving an error:
Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
The file exists on the path
My file db.json:
[{"id":"87","codigo":"00504.050.000.00.00","nomeCadastro":"GOIVO DOBRADO"},{"id":"86","codigo":"02023.050.000.10.02","nomeCadastro":"GERB ONEDIN"},{"id":"85","codigo":"00212.070.999.00.00","nomeCadastro":"CRIS SANT REAN"},{"id":"84","codigo":"01297.019.000.00.00","nomeCadastro":"ANTH VARIADO"}]
Just import data from json
file and use it
import data from '../config/db.json';
render(){
if(data){
// do whatever you want with data here,
}
....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With