Hello, can I get a little help here? I am trying to use popcorn time API from this site so I have installed the required packages in visual studio but when I paste the code it shows an error saying
"Error CS4033, The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'"
please, can you check it for me and correct it, I do really appreciate any help!
and I have taken API from here, https://popcornofficial.docs.apiary.io/#reference/show/pages
What I have tried:
//this is my code
private
void
button1_Click(
object
sender, EventArgs e)
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate
{
return
true
; };
var
baseAddress =
new
Uri(
"
https://tv-v2.api-fetch.website/"
);
using
(
var
httpClient =
new
HttpClient { BaseAddress = baseAddress })
using
(
var
response =
await
httpClient.GetAsync(
"
undefined"
))
string
responseData =
await
response.Content.ReadAsStringAsync();
private
async
void
button1_Click(
object
sender, EventArgs e)
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate
{
return
true
; };
var
baseAddress =
new
Uri(
"
https://tv-v2.api-fetch.website/"
);
using
(
var
httpClient =
new
HttpClient { BaseAddress = baseAddress })
using
(
var
response =
await
httpClient.GetAsync(
"
undefined"
))
string
responseData =
await
response.Content.ReadAsStringAsync();
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question
and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it.
Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
private async void button1_Click(object sender, EventArgs e)
{
var baseAddress = new Uri("https://tv-v2.api-fetch.website/movie/tt1457767");
using (var httpClient = new HttpClient { BaseAddress = baseAddress })
{
using (var response = await httpClient.GetAsync("undefined"))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
}