Closed yangkennyk closed 1 year ago
@yangkennyk Hi! Phoenix doesn’t provide this in its native API. Node modules won’t work since Phoenix doesn’t run on Node.
What you can do instead is use the Task.run(…)
(https://kasper.github.io/phoenix/api/task) API and use for example curl
or wget
.
I added an example to the documentation.
// Fetch a JSON
Task.run('/usr/bin/curl', ['-s', 'https://api.github.com/repos/kasper/phoenix/releases'], (task) => {
console.log('Result:', JSON.parse(task.output));
});
This may be a silly question but how can I make a fetch request on events?
I tried using node-fetch, got, axios but it doesn't seem to work and I'm not sure why.
I'm trying to interact with https://www.scriptkit.com/ via a fetch request.
thanks!