Hey, we are building a Chainlink API Consumer and need to also build an Adapter.
I am using this Chainlink Adapter Template:
I seem to be inputting the data wrong or have a stray ‘}’ in my input.
I was wondering if anyone knows what I’m doing wrong here, I could use a hand.
// Define custom parameters to be used by the adapter.
// Extra parameters can be stated in the extra object,
// with a Boolean value indicating whether or not they
// should be required.
const customParams = {
base: ['data'],//base: ['base', 'from', 'coin'],
quote: ['level'],//quote: ['quote', 'to', 'market'],
endpoint: false,
token_id: 0,
address: '0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB'
}
const createRequest = (input, callback) => {
// The Validator helps you validate the Chainlink request data
const validator = new Validator(callback, input, customParams)
const jobRunID = validator.validated.id
const endpoint = validator.validated.data.endpoint || 'price'
//const url = `https://min-api.cryptocompare.com/data/${endpoint}`
const url = `https://deep-index.moralis.io/api/v2/nft/${address}/metadata?chain=eth`
const fsym = validator.validated.data.toUpperCase() //.base
console.log(fsym);
const tsyms = validator.validated.data.toUpperCase() //.quote
const params = {
fsym,
tsyms
}
// This is where you would add method and headers
// you can add method like GET or POST and add it to the config
// The default is GET requests
// method = 'get'
// headers = 'headers.....'
const config = {
url,
params,
api_key: process.env.APP_ID
}
When I host it locally and run the Curl request I am getting a JSON error:
curl -X POST -H “content-type:application/json” “http://localhost:8080/” --data ‘{ “data”}’
% curl -X POST -H "content-type:application/json" "http://localhost:8080/" --data '{ "data"}'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>SyntaxError: Unexpected token } in JSON at position 8<br> at JSON.parse (<anonymous>...