Here is my question about using Svelte/Sapper
- I have a file in
/src/routes/login.js - According to Sapper doc, it will create an API endpoint in
http://<my_domain>/login, which it does - Now in
login.js, I would like to call another API server, assume that it ishttp://another_server/auth - No matter how I use the
fetchfunction:fetch("http://another_server/auth"),this.fetch("http://another_server/auth"), Svelte responses:(this.)fetch is not defined. - The documentation said that it should be run within
preload(), so I wrap the fetch underexport async function preload(){}, it did not work
So my question is: other than using axios, can I keep on using fetch in server side API request?
Just tested in the template [slug].json.js file, when I add the (this.)fetch function, it did not compile, same error: (this.)fetch is not defined
Thank you very much.