I’m trying to fetch the price of $SLI from ICPSwap into a webpage. Here is a Javascript code that isn’t working as expected. Is there anything I’m doing wrong? Please advice:
// Import the required dependencies
import { Principal } from “@dfinity/principal”;
import { Actor, HttpAgent } from ‘@dfinity/agent’;
import fetch from ‘isomorphic-fetch’;
async function getPrice() {
const host = “https://ic0.io”;
const agent = new HttpAgent({ fetch, host });
const canisterId = ‘yr4hc-viaaa-aaaag-qcirq-cai’; // ICPSwap canister ID
const actor = Actor.createActor(canisterId, {
agent,
canisterId: Principal.fromText(canisterId),
});
Do you have any error messages when running the code?
And what specific outcome are you aiming to achieve?
If it’s convenient for you, could you please record a video of the code execution and the error messages and send it to us at “contact@icpswap.org”? Let us see how we can help you!
I appreciate your response. I aim pull the number of ICPs required per slice or the number of slices required per ICP and proceed display on page. I thought I was missing some dependencies, that’s why i posted here. I can get from from Internet Computer dashboard using pair ID. However, the code presented doesn’t seem to fetch price on webpage. I’ll contact your team as suggested. Thank you.