Hi @miedumni
First off, welcome to the Pipedream community. Happy to have you!
Customizing the default scaffolding that comes with an app can be a bit confusing at first, but once you get the hang of it, it opens up many many doors for you.
Let’s start with the default scaffolding when you start the action from scratch:
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
line: {
type: "app",
app: "line",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://notify-api.line.me/api/status`,
headers: {
Authorization: `Bearer ${this.line.$auth.oauth_access_token}`,
},
})
},
}
Pipedream handles the authorization of the request for you. So you don’t need to modify the headers whatsoever.
The only portion you need to concern yourself with is to modifying the endpoint and body of the request. So if you’re trying to send the /api/notify
endpoint, and pass the { message: 'something to push' }
body to that endpoint, then only modify the url
, method
, and the data
of the request:
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
line: {
type: "app",
app: "line",
}
},
async run({steps, $}) {
return await axios($, {
method: 'post',
url: `https://notify-api.line.me/api/notify`,
headers: {
Authorization: `Bearer ${this.line.$auth.oauth_access_token}`,
},
data: { message: 'something to push' }
})
},
}
Axios will automatically handle the Content-Type
header, and Access-Control-Allow-Origin
is a browser concern, not a server side concern. Your axios request is executed within a server, not from your browser directly.
Hope this helps!