Depending on your setup, you may need to enable CORS to gain access
For security reasons, browsers restrict cross-origin HTTP requests initiated from scripts. Only in a local environment does the REST API simulate CORS enabled.
If you are getting a warning about the cross origin headers then you will need to set it up.
If you simply want to enable but don’t want to add any code snippets, you can simply install CoCart CORS Support plugin.