How can I do a http request on the snowpack devserver? #3212
Answered
by
TheEpicFace007
TheEpicFace007
asked this question in
Troubleshooting
-
I am trying to do a request on my bundle when my bundle is in development mode however I am not being able to get to do the request. When I do so the request always return 0. Here is how I do the request: const PORT = 80;
const BASE_URL = "http://192.168.2.235";
export interface FileResponse {
path: string;
filename: string;
type: string;
}
export async function getPics(category: Category, offset: number, perPage = 20): Promise<FileResponse[]> {
console.log(fetch.toString())
const urlParams = new URLSearchParams();
const url = new URL(BASE_URL + `/api/v1/pics`);
urlParams.append("offset", offset.toString());
urlParams.append("per-page", perPage.toString());
urlParams.append("category", category);
url.search = urlParams.toString();
const request = new XMLHttpRequest()
const response = await fetch(url.toString(), {
mode: "no-cors",
method: "GET",
cache: "default"
});
console.log(response)
console.log(response.text())
const responseData = await response.text()
console.log(responseData)
return [];
}
getPics(Category.any, 0); Here is the response if it can help:
Am I doing something wrong? |
Beta Was this translation helpful? Give feedback.
Answered by
TheEpicFace007
Apr 25, 2021
Replies: 1 comment
-
nvm I fixed the issue using this video https://youtu.be/4KHiSt0oLJ0 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TheEpicFace007
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nvm I fixed the issue using this video https://youtu.be/4KHiSt0oLJ0