0

this used to be my code in older carto.js

cartodb.SQL({user: 'user'}).execute(sqlquery).done(function (data){
  console.log(data);
}

how to readapt it in newer cartojs 4.0 beta

1 Answer 1

0

You can use any HTTP client like axios (example here) or just use the Fetch API if you are OK on the browsers that support it nowadays.

3
  • Thank You so much for your answer, you saved my day. I was really wondering where it went in the new JS. Commented Mar 6, 2018 at 16:05
  • Can we Commit Changes using axios ? Commented Mar 6, 2018 at 16:08
  • Again that's independant from the library, to commit changes to your data you need to pass your API key on the request so your call to the SQL API is authenticated. You don't want to do this in a public facing application of course since your API key enables full access to your account. On this training material you have details on how to create a function that is accessible to the anonymous user but that also allows to make changes.
    – Jorge Sanz
    Commented Mar 6, 2018 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.